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.

537 lines
17 KiB

2 years ago
2 years ago
2 years ago
  1. <template>
  2. <div class="box">
  3. <div style="position: relative">
  4. <div class="middlebox">
  5. <div class="contenttitle">
  6. 职业病设置 /
  7. <span class="contenttitleBold"
  8. >毒害因素</span
  9. >
  10. </div>
  11. <div class="seachinput">
  12. <el-select
  13. v-model="department"
  14. placeholder="请搜索"
  15. filterable
  16. :filter-method="remoteMethodes"
  17. default-first-option
  18. @change="quckDepartments"
  19. clearable
  20. size="small"
  21. >
  22. <el-option
  23. v-for="item in quckDepartment"
  24. :key="item.id"
  25. :label="item.displayName"
  26. :value="item.id"
  27. >
  28. </el-option>
  29. </el-select>
  30. </div>
  31. </div>
  32. <div style="display: block; margin-top: 7px; margin-right: 110px">
  33. <div style="background-color: #fff; padding: 15px; border-radius: 8px">
  34. <div id="printTest">
  35. <el-table
  36. :data="tableData"
  37. row-key="id"
  38. class="el-table__body-wrapper tbody"
  39. @row-click="rowick"
  40. highlight-current-row
  41. :height="window.pageHeight < 600 ? 480 : window.pageHeight - 130"
  42. ref="tableData"
  43. >
  44. <el-table-column prop="id" label="编号" width="300">
  45. </el-table-column>
  46. <el-table-column prop="displayName" label="名称" width="">
  47. </el-table-column>
  48. <el-table-column prop="poisonTypeId" label="毒害类别">
  49. <template slot-scope="scope">
  50. <div>
  51. {{ dddw(poisonType, "id", scope.row.poisonTypeId, "displayName") }}
  52. </div>
  53. </template>
  54. </el-table-column>
  55. <el-table-column prop="creatorName" label="创建者" width="">
  56. </el-table-column>
  57. <el-table-column prop="lastModifierName" label="修改者" width="">
  58. </el-table-column>
  59. <!-- <el-table-column prop="simpleCode" label="简称" width="180">
  60. </el-table-column> -->
  61. <el-table-column prop="creationTime" label="创建时间" width="200">
  62. <template slot-scope="scope">
  63. {{ scope.row.creationTime | dateFormat }}
  64. </template>
  65. </el-table-column>
  66. <el-table-column
  67. prop="lastModificationTime"
  68. label="修改时间"
  69. width="200"
  70. >
  71. <template slot-scope="scope">
  72. {{ scope.row.lastModificationTime | dateFormat }}
  73. </template>
  74. </el-table-column>
  75. <el-table-column label="操作" width="" align="center">
  76. <template>
  77. <el-tag
  78. class="move"
  79. style="
  80. cursor: move;
  81. background-color: rgb(245, 245, 245);
  82. border: none;
  83. "
  84. draggable="true"
  85. >
  86. <i
  87. class="el-icon-d-caret"
  88. style="width: 1rem; height: 1rem; color: rgb(113, 113, 113)"
  89. ></i>
  90. </el-tag>
  91. </template>
  92. </el-table-column>
  93. </el-table>
  94. </div>
  95. </div>
  96. </div>
  97. <!-- 按钮区域 -->
  98. <div style="margin-left: 10px;margin-top: 3%;position: absolute;top: 0;right: 0;">
  99. <el-button type="" @click="add" class="commonbutton">新增</el-button>
  100. <div style="margin-top: 10px">
  101. <el-button type="" @click="edlits" class="commonbutton">编辑</el-button>
  102. </div>
  103. <div style="margin-top: 10px">
  104. <el-button type="" @click="deleteid" class="deleteButton"
  105. >删除</el-button
  106. >
  107. </div>
  108. <div style="margin-top: 10px">
  109. <el-button type="" @click="topping" class="commonbutton"
  110. >置顶</el-button
  111. >
  112. </div>
  113. <div style="margin-top: 10px">
  114. <el-button type="" @click="toppings" class="commonbutton"
  115. >置底</el-button
  116. >
  117. </div>
  118. <div style="margin-top: 10px">
  119. <el-button
  120. type=""
  121. :disabled="isshow"
  122. @click="assertion"
  123. class="commonbutton"
  124. >排序</el-button
  125. >
  126. </div>
  127. <div style="margin-top: 10px">
  128. <el-button
  129. type=""
  130. :disabled="isshow"
  131. @click="cancellation"
  132. class="commonbutton"
  133. >取消</el-button
  134. >
  135. </div>
  136. </div>
  137. <!-- <div class="cancelorconfirm"></div> -->
  138. <!-- 新增或者编辑弹框 -->
  139. <el-dialog
  140. :title="title == 1 ? '新增' : '修改'"
  141. :visible.sync="dialogVisible"
  142. width="75%" :append-to-body="true"
  143. :close-on-click-modal="false"
  144. >
  145. <el-form ref="form" :model="form" label-width="80px">
  146. <el-row>
  147. <el-col :span="8">
  148. <el-form-item label="编号">
  149. <el-input
  150. v-model="form.id"
  151. style="width: 65%"
  152. disabled
  153. size="small"
  154. ></el-input>
  155. </el-form-item>
  156. </el-col>
  157. <el-col :span="8">
  158. <el-form-item label="名称">
  159. <el-input
  160. ref="refinput"
  161. v-model="form.displayName"
  162. style="width: 65%"
  163. size="small"
  164. ></el-input>
  165. </el-form-item>
  166. </el-col>
  167. <el-col :span="8">
  168. <el-form-item label="毒害类别">
  169. <el-select
  170. v-model="form.poisonTypeId"
  171. placeholder="请选择毒害类别"
  172. size="small"
  173. >
  174. <el-option v-for="item in poisonType"
  175. :key="item.id"
  176. :label="item.displayName"
  177. :value="item.id"></el-option>
  178. </el-select>
  179. </el-form-item>
  180. </el-col>
  181. </el-row>
  182. <el-row>
  183. <el-divider></el-divider>
  184. <el-col :span="4" style="margin-left: 15px">
  185. <el-form-item label="创建者">
  186. <el-input v-model="form.creatorName" disabled size="small"></el-input>
  187. </el-form-item>
  188. </el-col>
  189. <el-col :span="6">
  190. <el-form-item label="创建时间">
  191. <el-input
  192. :value="form.creationTime | dateFormat"
  193. disabled
  194. size="small"
  195. ></el-input>
  196. </el-form-item>
  197. </el-col>
  198. <el-col :span="4">
  199. <el-form-item label="修改者">
  200. <el-input v-model="form.lastModifierName" disabled size="small"></el-input>
  201. </el-form-item>
  202. </el-col>
  203. <el-col :span="6">
  204. <el-form-item label="修改时间">
  205. <el-input
  206. style="width: 85%"
  207. :value="form.lastModificationTime | dateFormat"
  208. disabled
  209. size="small"
  210. ></el-input>
  211. </el-form-item>
  212. </el-col>
  213. </el-row>
  214. </el-form>
  215. <span slot="footer" class="dialog-footer">
  216. <el-button @click="dialogVisible = false" class="difference"> </el-button>
  217. <el-button type="primary" @click="addoredit" class="commonbutton"
  218. > </el-button
  219. >
  220. </span>
  221. </el-dialog>
  222. </div>
  223. </div>
  224. </template>
  225. <script>
  226. import Sortable from "sortablejs";
  227. import { mapState } from "vuex";
  228. import {
  229. examinationlist,
  230. newphysical,
  231. listsid,
  232. Modifiers,
  233. deletecol,
  234. medicaltopbottom,
  235. examinationdragging,
  236. } from "../../request/systemapi";
  237. import { postapi } from '@/api/api';
  238. import { deepCopy,dddw } from "../../utlis/proFunc";
  239. export default {
  240. data() {
  241. return {
  242. isshow: true,
  243. dialogVisible: false,
  244. title: 1,
  245. form: {
  246. displayName: "",
  247. },
  248. tableData: [],
  249. initTableData: [],
  250. curRow: {},
  251. department:"",
  252. quckDepartment:[],
  253. poisonType:[]
  254. };
  255. },
  256. created() {
  257. this.getbaselist()
  258. this.getlist();
  259. },
  260. mounted() {
  261. this.rowDrop();
  262. },
  263. computed: {
  264. ...mapState(["window"]),
  265. },
  266. methods: {
  267. dddw,
  268. getbaselist(){
  269. postapi("/api/app/PoisonType/GetList").then((res) => {
  270. if(res.code!=-1){
  271. this.poisonType = [...res.data];
  272. }
  273. });
  274. },
  275. //点击列表通过id查询
  276. rowick(row) {
  277. this.curRow = { ...row };
  278. // listsid(row.id).then((res) => {
  279. // if(res.code!=-1){
  280. // this.curRow = { ...res.data };
  281. // }
  282. // // this.form = res.data;
  283. // });
  284. },
  285. remoteMethodes(keyWords) {
  286. if (keyWords) {
  287. this.quckDepartment = [];
  288. this.initTableData.forEach((item) => {
  289. if (
  290. item.displayName.toLowerCase().indexOf(keyWords.toLowerCase()) >
  291. -1 ||
  292. item.simpleCode.toLowerCase().indexOf(keyWords.toLowerCase()) > -1
  293. // || item.shortName.toLowerCase().indexOf(keyWords.toLowerCase()) > - 1
  294. ) {
  295. this.quckDepartment.push(item);
  296. }
  297. });
  298. } else {
  299. this.quckDepartment = [...this.initTableData];
  300. }
  301. },
  302. quckDepartments(e) {
  303. if (e) {
  304. this.tableData.forEach((item,index) => {
  305. if (e == item.id) {
  306. this.$refs["tableData"].setCurrentRow(item);
  307. this.rowick(item);
  308. this.searchup(item,index)
  309. }
  310. });
  311. } else {
  312. this.remoteMethodes();
  313. }
  314. },
  315. searchup(data,index) {
  316. if (index == 0) {
  317. index = 1;
  318. }
  319. const targetTop = this.$refs["tableData"].$el.querySelectorAll('.el-table__body tr')[index-1].getBoundingClientRect().top
  320. const containerTop = this.$refs["tableData"].$el.querySelector('.el-table__body').getBoundingClientRect().top
  321. const scrollParent = this.$refs["tableData"].$el.querySelector('.el-table__body-wrapper')
  322. scrollParent.scrollTop = targetTop - containerTop
  323. },
  324. cancellation() {
  325. this.$message.info("取消操作");
  326. this.isshow = true;
  327. this.getlist();
  328. },
  329. //确定排序
  330. assertion() {
  331. const result = [];
  332. this.tableData.forEach((item, index) => {
  333. // index 从0开始的, 你的displayOrder从大到小排
  334. // const currentDisplayOrder = this.tableData.length -1
  335. // const currentDisplayOrder = this.initTableData[index].displayOrder;
  336. // if (item.displayOrder != currentDisplayOrder) {
  337. // 如果它的displayOrder和它当前所在的位置不同代表挪动过位置
  338. result.push({ id: item.id, displayOrder: index+1 });
  339. // }
  340. });
  341. postapi("/api/app/Poison/UpdateSortMany",{ itemList: result }).then((res) => {
  342. if(res.code!=-1){
  343. this.getlist();
  344. this.isshow = true;
  345. //this.$message.success('操作成功')
  346. }
  347. });
  348. },
  349. //初始化
  350. rowDrop() {
  351. this.$nextTick(() => {
  352. const tbody = document.querySelector(".el-table__body-wrapper tbody");
  353. const _this = this;
  354. Sortable.create(tbody, {
  355. handle: ".move",
  356. animation: 300,
  357. // 指定父元素下可被拖拽的子元素
  358. // draggable: ".module-manager .el-table__row",
  359. onChoose({oldIndex}){
  360. _this.$refs['tableData'].setCurrentRow(_this.tableData[oldIndex]);
  361. _this.rowick(_this.tableData[oldIndex])
  362. },
  363. onEnd({ newIndex, oldIndex }) {
  364. // console.log(arr);
  365. _this.isshow = false;
  366. const currRow = _this.tableData.splice(oldIndex, 1)[0];
  367. _this.tableData.splice(newIndex, 0, currRow);
  368. _this.tableData.map((item, index) => {
  369. if (index == newIndex && index == oldIndex) {
  370. // console.log(item, "新数据");
  371. } else if (index == oldIndex) {
  372. } else if (index == newIndex) {
  373. }
  374. });
  375. },
  376. });
  377. });
  378. },
  379. //置底置顶
  380. topping() {
  381. this.form = { ...this.curRow };
  382. if (this.form.id == undefined) {
  383. this.$message.warning("请选择操作的数据");
  384. } else {
  385. postapi("/api/app/Poison/UpdateManySort",{poisonId:this.form.id, sortType:1}).then((res) => {
  386. if(res.code!=-1){
  387. this.getlist();
  388. //this.$message.success('操作成功')
  389. }
  390. });
  391. }
  392. },
  393. toppings() {
  394. this.form = { ...this.curRow };
  395. if (this.form.id == undefined) {
  396. this.$message.warning("请选择操作的数据");
  397. } else {
  398. postapi("/api/app/Poison/UpdateManySort",{poisonId:this.form.id, sortType:2}).then((res) => {
  399. if(res.code!=-1){
  400. this.getlist();
  401. //this.$message.success('操作成功')
  402. }
  403. });
  404. }
  405. },
  406. //删除
  407. deleteid(row) {
  408. this.form = { ...this.curRow };
  409. if (this.form.id == undefined) {
  410. this.$message.warning("请选择删除的数据");
  411. } else {
  412. this.$confirm("是否确认删除,是否继续", "提示", {
  413. confirmButtonText: "确定",
  414. cancelButtonText: "取消",
  415. type: "warning",
  416. cancelButtonClass:"difference",
  417. confirmButtonClass:"commonbutton"
  418. })
  419. .then(() => {
  420. postapi("/api/app/Poison/Delete",{poisonId:this.form.id}).then((res) => {
  421. if(res.code!=-1){
  422. this.curRow=this.$options.data().curRow
  423. this.getlist();
  424. //this.$message.success('删除成功')
  425. }
  426. });
  427. })
  428. .catch(() => {});
  429. // deletecol(this.form.id).then((res) => {
  430. // console.log("删除成功");
  431. // this.getlist();
  432. // });
  433. }
  434. },
  435. //edlits编辑弹框
  436. edlits(row) {
  437. this.form = { ...this.curRow };
  438. if (this.form.id == undefined) {
  439. this.$message.warning("请选择操作的数据");
  440. } else {
  441. this.title = 2;
  442. this.dialogVisible = true;
  443. postapi("/api/app/Poison/Get",{poisonId:this.form.id}).then((res) => {
  444. if(res.code!=-1){
  445. this.form = res.data;
  446. }
  447. });
  448. }
  449. },
  450. //确定新增或者修改
  451. addoredit() {
  452. if (this.form.displayName == undefined || this.form.displayName == "") {
  453. this.$message.warning("请输入名称");
  454. } else {
  455. if (this.title == 1) {
  456. postapi("/api/app/Poison/Create",{ displayName: this.form.displayName,poisonTypeId:this.form.poisonTypeId }).then((res) => {
  457. // this.form.displayName = "";
  458. if(res.code!=-1){
  459. this.getlist();
  460. this.dialogVisible = false;
  461. //this.$message.success('新增成功')
  462. }
  463. });
  464. } else if (this.title == 2) {
  465. postapi("/api/app/Poison/Update",{poisonId:this.form.id,poisonTypeId:this.form.poisonTypeId, displayName: this.form.displayName }).then(
  466. (res) => {
  467. if(res.code!=-1){
  468. this.getlist();
  469. this.dialogVisible = false;
  470. //this.$message.success('修改成功')
  471. }
  472. }
  473. );
  474. }
  475. }
  476. },
  477. //新增弹框
  478. add() {
  479. this.dialogVisible = true;
  480. this.title = 1;
  481. this.form=this.$options.data().form
  482. this.$nextTick(() => {
  483. this.$refs.refinput.focus();
  484. });
  485. },
  486. //
  487. getlist() {
  488. postapi("/api/app/Poison/GetList").then((res) => {
  489. if(res.code!=-1){
  490. this.initTableData = [...res.data];
  491. this.tableData = res.data;
  492. this.quckDepartment=[...res.data]
  493. }
  494. });
  495. },
  496. },
  497. };
  498. </script>
  499. <style scoped>
  500. @import "../../assets/css/global_button.css";
  501. @import "../../assets/css/global_dialog.css";
  502. @import "../../assets/css/global_table.css";
  503. @import "../../assets/css/global_form.css";
  504. @import "../../assets/css/global_input.css";
  505. @import "../../assets/css/global.css";
  506. .box {
  507. display: flex;
  508. flex-direction: column;
  509. }
  510. :deep .el-form-item {
  511. margin-bottom: 14px;
  512. }
  513. /* el-dialog的头部样式 */
  514. :deep .el-dialog__header {
  515. padding: 11px 20px 11px;
  516. }
  517. /* el-dialog的主体样式 */
  518. :deep .el-dialog__body {
  519. padding: 0px 20px 0px;
  520. }
  521. /* el-divider样式 */
  522. :deep .el-divider--horizontal {
  523. margin: 0px 0 12px;
  524. }
  525. /* el-dialog的底部样式 */
  526. :deep .el-dialog__footer {
  527. padding: 0px 20px 14px;
  528. }
  529. .seachinput {
  530. width: 250px;
  531. margin-right: 110px;
  532. }
  533. :deep .seachinput .el-select {
  534. width: 100%;
  535. }
  536. </style>