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 = false;
  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 = false;
  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. this.ites=res.data
  483. let dq = res.data;
  484. if (dq.length > 0) {
  485. dq.forEach((element) => {
  486. let bb = { displayName: element.displayName, id: element.id };
  487. this.ites.push(bb);
  488. });
  489. }
  490. });
  491. },
  492. // 获取项目类别接口
  493. posjectlist() {
  494. projectlist().then((res) => {
  495. console.log(res);
  496. this.projectid = res.data;
  497. });
  498. },
  499. handlechang(value, direction, movedkeys) {
  500. console.log(value);
  501. console.log(direction);
  502. console.log(movedkeys);
  503. },
  504. //取消按钮
  505. cancellation() {
  506. this.$message.info("取消操作");
  507. this.isshow = true;
  508. this.getlist();
  509. },
  510. //确定排序
  511. assertion() {
  512. const result = [];
  513. this.tableData.forEach((item, index) => {
  514. // index 从0开始的, 你的displayOrder从大到小排
  515. console.log(item.id);
  516. // const currentDisplayOrder = this.tableData.length -1
  517. const currentDisplayOrder = this.initTableData[index].displayOrder;
  518. if (item.displayOrder != currentDisplayOrder) {
  519. // 如果它的displayOrder和它当前所在的位置不同代表挪动过位置
  520. result.push({ id: item.id, displayOrder: currentDisplayOrder });
  521. }
  522. });
  523. // console.log('assertion', result);
  524. barcodedraganddrop({ itemList: result }).then((res) => {
  525. this.$message.success("操作成功");
  526. this.isshow = true;
  527. this.getlist();
  528. });
  529. },
  530. //初始化
  531. rowDrop() {
  532. this.$nextTick(() => {
  533. const tbody = document.querySelector(".el-table__body-wrapper tbody");
  534. const _this = this;
  535. Sortable.create(tbody, {
  536. handle: ".move",
  537. animation: 300,
  538. // 指定父元素下可被拖拽的子元素
  539. // draggable: ".module-manager .el-table__row",
  540. onEnd({ newIndex, oldIndex }) {
  541. // console.log(arr);
  542. _this.isshow = false;
  543. const currRow = _this.tableData.splice(oldIndex, 1)[0];
  544. _this.tableData.splice(newIndex, 0, currRow);
  545. _this.tableData.map((item, index) => {
  546. if (index == newIndex && index == oldIndex) {
  547. // console.log(item, "新数据");
  548. } else if (index == oldIndex) {
  549. } else if (index == newIndex) {
  550. }
  551. });
  552. console.log(_this.tableData.map((item) => item.displayOrder));
  553. },
  554. });
  555. });
  556. },
  557. //置底
  558. setlow() {
  559. if (this.form.id == undefined) {
  560. this.$message.warning("请选择操作的数据");
  561. } else {
  562. barcodedetopbottom(this.form.id, 2).then((res) => {
  563. console.log(res, "3333");
  564. this.getlist();
  565. this.$message.success("操作成功");
  566. });
  567. }
  568. },
  569. //置顶
  570. topping() {
  571. if (this.form.id == undefined) {
  572. this.$message.warning("请选择操作的数据");
  573. } else {
  574. barcodedetopbottom(this.form.id, 1).then((res) => {
  575. this.$message.success("操作成功");
  576. this.getlist();
  577. });
  578. }
  579. },
  580. //删除
  581. deleteid() {
  582. if (this.form.id == undefined) {
  583. this.$message.warning("请选择操作的数据");
  584. } else {
  585. barcodedeleteid(this.form.id).then((res) => {
  586. console.log(res);
  587. this.$message.success("删除成功");
  588. this.getlist();
  589. });
  590. }
  591. },
  592. //编辑弹框
  593. editreport() {
  594. if (this.form.id == undefined) {
  595. this.$message.warning("请选择操作的数据");
  596. } else {
  597. this.dialogVisible = true;
  598. this.title = 2;
  599. //获取标本类型id
  600. specimenlist(this.pages).then((res) => {
  601. this.sampleTypeId = res.data.items;
  602. });
  603. // 获取标本容器Id
  604. containerlist(this.pages).then((res) => {
  605. this.sampleContainerId = res.data.items;
  606. });
  607. samplegropid(this.form.id).then((res) => {
  608. this.form = res.data;
  609. });
  610. }
  611. },
  612. //确定新增或者编辑
  613. addoredit() {
  614. this.$refs.form.validate((v) => {
  615. if (v) {
  616. if (this.title == 1) {
  617. samplegroup({
  618. displayName: this.form.displayName,
  619. sampleTypeId: this.form.sampleTypeId,
  620. sampleContainerId: this.form.sampleContainerId,
  621. }).then((res) => {
  622. this.$message.success("新增成功");
  623. this.getlist();
  624. this.dialogVisible = false;
  625. });
  626. } else if (this.title == 2) {
  627. barcodeediting(this.form.id, {
  628. displayName: this.form.displayName,
  629. sampleTypeId: this.form.sampleTypeId,
  630. sampleContainerId: this.form.sampleContainerId,
  631. }).then((res) => {
  632. this.$message.success("修改成功");
  633. this.dialogVisible = false;
  634. this.getlist();
  635. });
  636. }
  637. }
  638. });
  639. },
  640. //新增弹框
  641. addll() {
  642. this.dialogVisible = true;
  643. this.title = 1;
  644. this.form = {};
  645. //获取标本类型id
  646. specimenlist(this.pages).then((res) => {
  647. this.sampleTypeId = res.data.items;
  648. console.log(res);
  649. });
  650. // 获取标本容器Id
  651. containerlist(this.pages).then((res) => {
  652. this.sampleContainerId = res.data.items;
  653. console.log(res, "11111");
  654. });
  655. },
  656. rowick(row) {
  657. samplegropid(row.id).then((res) => {
  658. this.form = res.data;
  659. });
  660. sampleasbitemid(row.id).then((res) => {
  661. let dq = res.data;
  662. if (dq.length > 0) {
  663. this.rightdata = [];
  664. dq.forEach((element) => {
  665. let bb = { displayName: element.displayName, id: element.id };
  666. this.rightdata.push(bb);
  667. });
  668. }
  669. // this.rightdata = res.data;
  670. // console.log(res);
  671. });
  672. },
  673. getlist() {
  674. this.loading = true;
  675. groupinglist(this.pages).then((res) => {
  676. this.loading = false;
  677. this.tableData = res.data.items;
  678. this.initTableData = [...res.data.items];
  679. console.log(res);
  680. });
  681. },
  682. //ary1 需要追加的数据 ary2目标数组
  683. updatedate() {
  684. this.ary1.forEach((item) => {
  685. let iscz = false;
  686. this.ary2.forEach((item2) => {
  687. if (item2.id == item.id) {
  688. iscz = true;
  689. }
  690. });
  691. if (!iscz) {
  692. console.log(item.id);
  693. this.ary2.push(item);
  694. // this.allid.push({ id: item.id });
  695. }
  696. });
  697. },
  698. },
  699. };
  700. </script>
  701. <style scoped>
  702. .confirmcancellation {
  703. margin-left: 40%;
  704. }
  705. .Selectbutton {
  706. margin-left: 3%;
  707. }
  708. .activetext {
  709. background: rgb(185, 203, 235);
  710. }
  711. .weixuan {
  712. text-align: center;
  713. line-height: 20px;
  714. background: rgb(185, 203, 235);
  715. }
  716. .leftbox {
  717. width: 200px;
  718. height: 240px;
  719. border: 1px solid #ccc;
  720. margin-left: 6%;
  721. }
  722. .instrumentcategory {
  723. width: 100%;
  724. display: flex;
  725. margin-left: 15%;
  726. }
  727. .box {
  728. display: flex;
  729. }
  730. </style>