You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

704 lines
20 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <div class="box">
  3. <div style="width: 95%">
  4. <el-card>
  5. <el-table
  6. :data="tableData"
  7. style="width: 100%"
  8. row-key="id"
  9. class="el-table__body-wrapper tbody"
  10. @row-click="rowclick"
  11. highlight-current-row
  12. >
  13. <el-table-column prop="id" label="编号" width="300">
  14. </el-table-column>
  15. <el-table-column prop="displayName" label="名称" width="130">
  16. </el-table-column>
  17. <el-table-column prop="creatorName" label="创建者" width="150">
  18. </el-table-column>
  19. <el-table-column prop="creationTime" label="创建时间" width="200">
  20. <template slot-scope="scope">
  21. {{ scope.row.creationTime | dateFormat }}
  22. </template>
  23. </el-table-column>
  24. <el-table-column prop="lastModifierName" label="修改者" width="">
  25. </el-table-column>
  26. <el-table-column
  27. prop="lastModificationTime"
  28. label="修改时间"
  29. width="200"
  30. >
  31. <template slot-scope="scope">
  32. {{ scope.row.lastModificationTime | dateFormat }}
  33. </template>
  34. </el-table-column>
  35. <el-table-column label="操作" width="">
  36. <template>
  37. <el-tag
  38. class="move"
  39. style="cursor: move; margin-left: 15px"
  40. draggable="true"
  41. >
  42. <i
  43. class="el-icon-d-caret"
  44. style="width: 1rem; height: 1rem"
  45. ></i>
  46. </el-tag>
  47. </template>
  48. </el-table-column>
  49. </el-table>
  50. <!-- <comp-table
  51. :tableData="tableData"
  52. :tableHeader="tableHeader"
  53. @clickevents="rowclick"
  54. ref="singleTable"
  55. >
  56. </comp-table> -->
  57. </el-card>
  58. <!-- 弹框 -->
  59. <el-dialog
  60. :title="title == 1 ? '新增' : '编辑'"
  61. :visible.sync="dialogVisible"
  62. width="75%"
  63. >
  64. <el-form ref="form" :model="form" label-width="80px" :rules="rules">
  65. <el-row>
  66. <el-col :span="8">
  67. <el-form-item label="名称" prop="displayName">
  68. <el-input
  69. v-model="form.displayName"
  70. style="width: 80%"
  71. ></el-input>
  72. </el-form-item>
  73. </el-col>
  74. <el-col :span="8">
  75. <el-form-item label="价格" prop="price">
  76. <el-input v-model="form.price" style="width: 80%"></el-input>
  77. </el-form-item>
  78. </el-col>
  79. <el-col :span="8">
  80. <el-form-item label="适用性别" prop="forSexId">
  81. <el-select v-model="form.forSexId" placeholder="请选择">
  82. <el-option
  83. v-for="item in forSexId"
  84. :key="item.id"
  85. :label="item.displayName"
  86. :value="item.id"
  87. >
  88. </el-option>
  89. </el-select>
  90. </el-form-item>
  91. </el-col>
  92. <el-col :span="8">
  93. <el-form-item label="启用标志" prop="isActive">
  94. <el-select v-model="form.isActive" placeholder="请选择">
  95. <el-option
  96. v-for="item in isActive"
  97. :key="item.value"
  98. :label="item.label"
  99. :value="item.value"
  100. >
  101. </el-option>
  102. </el-select>
  103. </el-form-item>
  104. </el-col>
  105. <el-col :span="8">
  106. <el-form-item label="备注" prop="remark">
  107. <el-input v-model="form.remark" style="width: 80%"></el-input>
  108. </el-form-item>
  109. </el-col>
  110. </el-row>
  111. <el-divider></el-divider>
  112. <el-row>
  113. <el-col :span="6">
  114. <el-form-item label="创建者">
  115. <el-input v-model="form.creatorName" disabled></el-input>
  116. </el-form-item>
  117. </el-col>
  118. <el-col :span="6">
  119. <el-form-item label="创建时间">
  120. <el-input
  121. :value="form.creationTime | dateFormat"
  122. disabled
  123. ></el-input>
  124. </el-form-item>
  125. </el-col>
  126. <el-col :span="6">
  127. <el-form-item label="修改者">
  128. <el-input v-model="form.lastModifierName" disabled></el-input>
  129. </el-form-item>
  130. </el-col>
  131. <el-col :span="6">
  132. <el-form-item label="修改时间">
  133. <el-input
  134. :value="form.lastModificationTime | dateFormat"
  135. disabled
  136. ></el-input>
  137. </el-form-item>
  138. </el-col>
  139. </el-row>
  140. <!-- -->
  141. </el-form>
  142. <!-- -->
  143. <span slot="footer" class="dialog-footer">
  144. <el-button @click="dialogVisible = false"> </el-button>
  145. <el-button type="primary" @click="onsbmit"> </el-button>
  146. </span>
  147. </el-dialog>
  148. <!-- -->
  149. <span style="margin-top: 10px; padding: 5px; margin-left: 20.5%"
  150. >项目类别</span
  151. >
  152. <el-select
  153. v-model="values"
  154. placeholder="请选择"
  155. @change="ischangs"
  156. style="margin-top: 5px"
  157. >
  158. <el-option
  159. v-for="item in projectid"
  160. :key="item.id"
  161. :label="item.displayName"
  162. :value="item.id"
  163. >
  164. </el-option>
  165. </el-select>
  166. <span style="margin-left: 10%; padding: 5px">搜索选择</span>
  167. <el-select
  168. filterable
  169. v-model="flitvalues"
  170. placeholder="请选择"
  171. style="margin-top: 5px"
  172. >
  173. <el-option
  174. v-for="item in filetelists"
  175. :key="item.id"
  176. :label="item.displayName"
  177. :value="item.id"
  178. >
  179. </el-option>
  180. </el-select>
  181. <div class="mainbox">
  182. <div class="mainleftbox">
  183. <div class="weixuan">未选项目</div>
  184. <div
  185. v-for="(item, index) in leftdata"
  186. :key="index"
  187. @click="clickPaixu(item, index)"
  188. @dblclick="shuanji(item, index)"
  189. :class="num === index ? 'activetext' : ''"
  190. style=""
  191. >
  192. <div>{{ item.displayName }}</div>
  193. </div>
  194. </div>
  195. <div class="Selectbutton">
  196. <div style="margin-top: 10px">
  197. <el-button @click="addall"
  198. >全添加<i class="el-icon-caret-right"></i
  199. ><i class="el-icon-caret-right"></i
  200. ></el-button>
  201. </div>
  202. <div style="margin-top: 10px">
  203. <el-button @click="addobj" style="width: 111px"
  204. >添加<i class="el-icon-caret-right"></i>
  205. </el-button>
  206. </div>
  207. <div style="margin-top: 10px">
  208. <el-button @click="removeright" style="width: 111px"
  209. >移去<i class="el-icon-caret-left"></i>
  210. </el-button>
  211. </div>
  212. <div style="margin-top: 10px">
  213. <el-button @click="allclear"
  214. >全移去<i class="el-icon-caret-left"></i
  215. ><i class="el-icon-caret-left"></i>
  216. </el-button>
  217. </div>
  218. </div>
  219. <div class="mainleftbox">
  220. <div class="weixuan">已选项目</div>
  221. <div
  222. v-for="(item, index) in rightdata"
  223. :key="index"
  224. @click="rightindex(item, index)"
  225. @dblclick="rightdelite(item, index)"
  226. :class="nums === index ? 'activetext' : ''"
  227. >
  228. <div>{{ item.displayName }}</div>
  229. </div>
  230. </div>
  231. </div>
  232. <div class="confirmcancellation">
  233. <el-button :disabled="isdislob" @click="Onsubmit">确定</el-button>
  234. <el-button :disabled="isdislob">取消</el-button>
  235. </div>
  236. </div>
  237. <!-- 按钮区域 -->
  238. <div style="margin-left: 10px; margin-top: 5%">
  239. <el-button type="primary" @click="add">新增</el-button>
  240. <el-button
  241. type="primary"
  242. @click="editpopup"
  243. style="margin-left: 0; margin-top: 10px"
  244. >编辑</el-button
  245. >
  246. <div style="margin-top: 10px">
  247. <el-button type="danger" @click="delets">删除</el-button>
  248. </div>
  249. <div style="margin-top: 10px">
  250. <el-button type="primary" @click="topping">置顶</el-button>
  251. </div>
  252. <div style="margin-top: 10px">
  253. <el-button type="primary" @click="toppings">置底</el-button>
  254. </div>
  255. <div style="margin-top: 10px">
  256. <el-button type="primary" :disabled="isshow" @click="assertion"
  257. >排序</el-button
  258. >
  259. </div>
  260. <div style="margin-top: 5px">
  261. <el-button type="primary" :disabled="isshow" @click="cancellation"
  262. >取消</el-button
  263. >
  264. </div>
  265. </div>
  266. </div>
  267. </template>
  268. <script>
  269. import { rowDrop } from "@/components/publicjs/public";
  270. import { getapi, postapi, putapi, deletapi } from "@/api/api";
  271. import { getporjectlists } from "@/request/commonapi";
  272. import compTable from "@/components/compTable.vue";
  273. import Sortable from "sortablejs";
  274. export default {
  275. components: { compTable },
  276. data() {
  277. return {
  278. num: 0,
  279. leftdata: [],
  280. filetelists: [],
  281. flitvalues: [],
  282. projectid: [],
  283. values: [],
  284. isshow: true,
  285. rules: {
  286. forSexId: [
  287. { required: true, message: "请选择性别", trigger: "change" },
  288. ],
  289. isActive: [
  290. { required: true, message: "请选择启用标志", trigger: "change" },
  291. ],
  292. displayName: [
  293. { required: true, message: "请输入名称", trigger: "blur" },
  294. ],
  295. price: [{ required: true, message: "请输入价格", trigger: "blur" }],
  296. remark: [{ required: true, message: "请输入备注", trigger: "blur" }],
  297. },
  298. form: {
  299. displayName: "",
  300. price: "",
  301. forSexId: "",
  302. isActive: "",
  303. remark: "",
  304. },
  305. isActive: [
  306. {
  307. value: "N",
  308. label: "否",
  309. },
  310. {
  311. value: "Y",
  312. label: "是",
  313. },
  314. ], //启用标志
  315. forSexId: [],
  316. dialogVisible: false,
  317. title: 1,
  318. pages: {
  319. SkipCount: 0,
  320. MaxResultCount: 100,
  321. Sorting: "displayOrder desc",
  322. },
  323. isNameIntoSummary: [
  324. {
  325. value: "N",
  326. label: "否",
  327. },
  328. {
  329. value: "Y",
  330. label: "是",
  331. },
  332. ], // 小结名称
  333. isResultIntoSummary: [
  334. {
  335. value: "N",
  336. label: "否",
  337. },
  338. {
  339. value: "Y",
  340. label: "是",
  341. },
  342. ], //进入小结
  343. tableData: [],
  344. initTableData: [],
  345. tableHeader: [
  346. // 表头信息,可根据minWidth修改宽度
  347. { prop: "id", label: "编号", minWidth: "150px" },
  348. { prop: `creatorName`, label: "创建者" },
  349. { prop: `creationTime`, label: "创建时间" },
  350. { prop: `lastModifierName`, label: "修改者" },
  351. { prop: `lastModificationTime`, label: "创建时间" },
  352. { prop: "result", label: "结果" },
  353. // { prop: "simpleCode", label: "拼音简码" },
  354. ],
  355. rightdata: [],
  356. isdislob: true,
  357. ary1: [],
  358. ary2: [],
  359. leftobj: {},
  360. rightobj: {},
  361. nums: 0,
  362. };
  363. },
  364. created() {
  365. this.getlist();
  366. this.gitprojectcategory();
  367. },
  368. mounted() {
  369. this.rowDrop();
  370. },
  371. methods: {
  372. Onsubmit() {
  373. let sampleGroupId = this.form.id;
  374. console.log(this.form.id);
  375. console.log(this.rightdata);
  376. let sdate = [];
  377. this.rightdata.forEach((element) => {
  378. let sss = { medicalPackageId: sampleGroupId, asbitemId: element.id };
  379. sdate.push(sss);
  380. });
  381. this.leftdata.forEach((element) => {
  382. let sss = { sampleGroupId: sampleGroupId, asbitemId: element.id };
  383. sdate.push(sss);
  384. });
  385. console.log(sdate);
  386. if (sampleGroupId == undefined) {
  387. this.$message.warning("请选择列表");
  388. } else {
  389. postapi("/api/app/medical-package-detail/many", sdate).then((res) => {
  390. this.$message.success("操作成功");
  391. this.isdislob = true;
  392. });
  393. }
  394. },
  395. //右侧点击选中
  396. rightindex(item, index) {
  397. this.nums = index;
  398. this.leftobj = item;
  399. console.log(this.leftobj);
  400. },
  401. //右侧双击
  402. rightdelite(item, index) {
  403. console.log(item);
  404. this.rightdata.splice(index, 1);
  405. this.leftdata.push(item);
  406. },
  407. //左侧双击事件
  408. shuanji(item, index) {
  409. console.log(item);
  410. this.leftdata.splice(index, 1);
  411. this.rightdata.push(item);
  412. },
  413. //全添加
  414. addall() {
  415. this.isdislob = false;
  416. if (this.leftdata.length > 0) {
  417. this.ary1 = this.leftdata;
  418. this.ary2 = this.rightdata;
  419. this.updatedate();
  420. this.leftdata = [];
  421. }
  422. },
  423. //左侧添加按钮
  424. addobj() {
  425. if (this.leftdata.length > 0) {
  426. this.isdislob = false;
  427. this.leftdata.splice(this.num, 1);
  428. this.rightdata.push(this.rightobj);
  429. }
  430. },
  431. //右移动
  432. removeright() {
  433. if (this.rightdata.length > 0) {
  434. this.rightdata.splice(this.nums, 1);
  435. this.leftdata.push(this.leftobj);
  436. this.isdislob = true;
  437. this.updatedate();
  438. }
  439. },
  440. //ary1 需要追加的数据 ary2目标数组
  441. updatedate() {
  442. this.ary1.forEach((item) => {
  443. let iscz = false;
  444. this.ary2.forEach((item2) => {
  445. if (item2.id == item.id) {
  446. iscz = true;
  447. }
  448. });
  449. if (!iscz) {
  450. console.log(item.id);
  451. this.ary2.push(item);
  452. // this.allid.push({ id: item.id });
  453. }
  454. });
  455. },
  456. clickPaixu(item, index) {
  457. this.rightobj = item;
  458. this.num = index;
  459. console.log(this.num);
  460. console.log(this.rightobj);
  461. },
  462. //q全移去
  463. allclear() {
  464. this.isdislob = false;
  465. if (this.rightdata.length > 0) {
  466. this.ary1 = this.rightdata;
  467. this.ary2 = this.leftdata;
  468. this.updatedate();
  469. this.rightdata = [];
  470. }
  471. },
  472. //获取项目类别 3a0b0b10-719f-5824-6956-8cb70f204013
  473. gitprojectcategory() {
  474. getapi("/api/app/item-type").then((res) => {
  475. this.projectid = res.data.items;
  476. });
  477. },
  478. //项目类别选择
  479. ischangs(v) {
  480. console.log(v);
  481. getapi(`/api/app/asbitem/in-item-type/${v}`).then((res) => {
  482. console.log(res);
  483. this.leftdata = res.data;
  484. });
  485. },
  486. //取消排序
  487. cancellation() {
  488. this.$message.info("取消操作");
  489. this.isshow = true;
  490. this.getlist();
  491. },
  492. //确定排序
  493. assertion() {
  494. const result = [];
  495. this.tableData.forEach((item, index) => {
  496. // index 从0开始的, 你的displayOrder从大到小排
  497. console.log(item.id);
  498. // const currentDisplayOrder = this.tableData.length -1
  499. const currentDisplayOrder = this.initTableData[index].displayOrder;
  500. if (item.displayOrder != currentDisplayOrder) {
  501. // 如果它的displayOrder和它当前所在的位置不同代表挪动过位置
  502. result.push({ id: item.id, displayOrder: currentDisplayOrder });
  503. }
  504. });
  505. putapi("/api/app/medicalpackage/updatesortmany", {
  506. itemList: result,
  507. }).then((res) => {
  508. this.$message.success("操作成功");
  509. this.isshow = true;
  510. this.getlist();
  511. });
  512. },
  513. //初始化
  514. rowDrop() {
  515. this.$nextTick(() => {
  516. const tbody = document.querySelector(".el-table__body-wrapper tbody");
  517. const _this = this;
  518. Sortable.create(tbody, {
  519. handle: ".move",
  520. animation: 300,
  521. onEnd({ newIndex, oldIndex }) {
  522. _this.isshow = false;
  523. const currRow = _this.tableData.splice(oldIndex, 1)[0];
  524. _this.tableData.splice(newIndex, 0, currRow);
  525. _this.tableData.map((item, index) => {
  526. if (index == newIndex && index == oldIndex) {
  527. // console.log(item, "新数据");
  528. } else if (index == oldIndex) {
  529. } else if (index == newIndex) {
  530. }
  531. });
  532. console.log(_this.tableData.map((item) => item.displayOrder));
  533. },
  534. });
  535. });
  536. },
  537. toppings() {
  538. if (this.form.id == undefined) {
  539. this.$message.warning("请选择操作的数据");
  540. } else {
  541. putapi(
  542. `/api/app/medicalpackage/updatemanysort?id=${
  543. this.form.id
  544. }&SortType=${2}`
  545. ).then((res) => {
  546. this.$message.success("操作成功");
  547. this.getlist();
  548. });
  549. }
  550. },
  551. topping() {
  552. if (this.form.id == undefined) {
  553. this.$message.warning("请选择操作的数据");
  554. } else {
  555. putapi(
  556. `/api/app/medicalpackage/updatemanysort?id=${
  557. this.form.id
  558. }&SortType=${1}`
  559. ).then((res) => {
  560. this.$message.success("操作成功");
  561. this.getlist();
  562. });
  563. }
  564. },
  565. //删除
  566. delets(row) {
  567. if (this.form.id == undefined) {
  568. this.$message.warning("请选择删除的数据");
  569. } else {
  570. this.$confirm("是否确认删除,是否继续?", "提示", {
  571. confirmButtonText: "确定",
  572. cancelButtonText: "取消",
  573. type: "warning",
  574. })
  575. .then(() => {
  576. deletapi(`/api/app/medical-package/${this.form.id}`).then((res) => {
  577. this.$message.success("删除成功");
  578. this.getlist();
  579. });
  580. })
  581. .catch(() => {});
  582. }
  583. },
  584. //编辑弹框
  585. editpopup() {
  586. if (this.form.id == undefined) {
  587. this.$message.warning("请点击选择操作的数据");
  588. } else {
  589. this.dialogVisible = true;
  590. this.title = 2;
  591. this.addtoedit();
  592. getapi(`/api/app/medical-package/${this.form.id}`).then((res) => {
  593. this.form = res.data;
  594. console.log(res);
  595. });
  596. }
  597. },
  598. //确定新增或者编辑
  599. onsbmit() {
  600. this.$refs.form.validate((v) => {
  601. if (v) {
  602. if (this.title == 1) {
  603. this.form.price = Number(this.form.price);
  604. postapi("/api/app/medical-package", this.form).then((res) => {
  605. this.$message.success("新增成功");
  606. this.getlist();
  607. this.dialogVisible = false;
  608. });
  609. } else if (this.title == 2) {
  610. putapi(`/api/app/medical-package/${this.form.id}`, this.form).then(
  611. (res) => {
  612. this.$message.success("修改成功");
  613. this.getlist();
  614. this.dialogVisible = false;
  615. }
  616. );
  617. }
  618. }
  619. });
  620. },
  621. rowclick(val) {
  622. getapi(`/api/app/medical-package/${val.id}`).then((res) => {
  623. this.form = res.data;
  624. console.log(res);
  625. });
  626. getapi(
  627. `/api/app/medical-package-detail/medical-package-in-asbitem?MedicalPackageId=${val.id}`
  628. ).then((res) => {
  629. console.log(res);
  630. this.rightdata = res.data;
  631. let dq = res.data;
  632. if (dq.length > 0) {
  633. this.rightdata = [];
  634. dq.forEach((element) => {
  635. let bb = { displayName: element.displayName, id: element.id };
  636. this.rightdata.push(bb);
  637. });
  638. }
  639. });
  640. },
  641. handleRowClick(Row) {
  642. console.log(Row);
  643. console.log("1");
  644. },
  645. // 新增或者编辑需要的类别
  646. addtoedit() {
  647. getapi("/api/app/sex").then((res) => {
  648. this.forSexId = res.data;
  649. });
  650. },
  651. //新增弹框
  652. add() {
  653. this.addtoedit();
  654. this.dialogVisible = true;
  655. this.title = 1;
  656. this.form = {};
  657. },
  658. getlist() {
  659. getapi("/api/app/medical-package/in-filter", this.pages).then((res) => {
  660. console.log(res);
  661. this.tableData = res.data.items;
  662. this.initTableData = [...res.data.items];
  663. });
  664. let that = this;
  665. },
  666. },
  667. };
  668. </script>
  669. <style scoped>
  670. .Selectbutton {
  671. margin-left: 3%;
  672. }
  673. .weixuan {
  674. text-align: center;
  675. line-height: 20px;
  676. background: rgb(185, 203, 235);
  677. }
  678. .confirmcancellation {
  679. margin-left: 45%;
  680. }
  681. .mainleftbox {
  682. width: 200px;
  683. height: 240px;
  684. border: 1px solid #ccc;
  685. margin-left: 6%;
  686. }
  687. .mainbox {
  688. display: flex;
  689. justify-content: center;
  690. margin-top: 20px;
  691. }
  692. .box {
  693. display: flex;
  694. }
  695. .activetext {
  696. background: rgb(185, 203, 235);
  697. }
  698. </style>