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.

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