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.

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