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.

615 lines
20 KiB

1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
  1. <template>
  2. <div class="mod-config">
  3. <!-- 条件查询 -->
  4. <el-form :inline="true" label-position="top" :model="searchData">
  5. <el-form-item label="BU">
  6. <el-select v-model="searchData.buDesc" placeholder="请选择" clearable style="width: 80px">
  7. <el-option
  8. v-for="i in userBuList"
  9. :key="i.buNo"
  10. :label="i.buDesc"
  11. :value="i.buDesc">
  12. </el-option>
  13. </el-select>
  14. </el-form-item>
  15. <el-form-item label="方法编码">
  16. <el-input v-model="searchData.methodNo" clearable style="width: 120px"></el-input>
  17. </el-form-item>
  18. <el-form-item label="方法名称">
  19. <el-input v-model="searchData.methodName" clearable style="width: 200px"></el-input>
  20. </el-form-item>
  21. <el-form-item label="检验类型">
  22. <el-select v-model="searchData.inspectionTypeNo" placeholder="请选择" style="width: 100px">
  23. <el-option label="全部" value=""></el-option>
  24. <el-option
  25. v-for="i in options"
  26. :key="i.inspectionTypeNo"
  27. :label="i.inspectionTypeName"
  28. :value="i.inspectionTypeNo">
  29. </el-option>
  30. </el-select>
  31. </el-form-item>
  32. <el-form-item label=" ">
  33. <el-button v-if="!authSearch" type="primary" @click="getDataList()">查询</el-button>
  34. <el-button v-if="!authSave" type="primary" @click="addModal()">新增</el-button>
  35. <download-excel
  36. :fields="fields()"
  37. :data="exportData"
  38. type="xls"
  39. :name="exportName"
  40. :header="exportHeader"
  41. :footer="exportFooter"
  42. :fetch="createExportData"
  43. :before-generate="startDownload"
  44. :before-finish="finishDownload"
  45. worksheet="导出信息"
  46. class="el-button el-button--primary el-button--medium">
  47. {{ "导出" }}
  48. </download-excel>
  49. </el-form-item>
  50. </el-form>
  51. <!-- 展示列表 -->
  52. <el-table
  53. :height="height"
  54. :data="dataList"
  55. @header-dragend="handleColumnResize"
  56. border
  57. v-loading="dataListLoading"
  58. style="width: 100%;">
  59. <el-table-column
  60. v-for="(item,index) in columnList" :key="index"
  61. :sortable="item.columnSortable"
  62. :prop="item.columnProp"
  63. :header-align="item.headerAlign"
  64. :show-overflow-tooltip="item.showOverflowTooltip"
  65. :align="item.align"
  66. :fixed="item.fixed===''?false:item.fixed"
  67. :min-width="item.columnWidth"
  68. :label="item.columnLabel">
  69. <template slot-scope="scope">
  70. <span v-if="!item.columnHidden">
  71. <span v-if="columnsProp.includes(item.columnProp)">{{ scope.row[`${item.columnProp}Desc`] }}</span>
  72. <span v-else>
  73. {{ scope.row[item.columnProp] }}
  74. </span>
  75. </span>
  76. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
  77. </template>
  78. </el-table-column>
  79. <el-table-column
  80. fixed="right"
  81. header-align="center"
  82. align="center"
  83. width="130"
  84. label="操作">
  85. <template slot-scope="scope">
  86. <a v-if="!authUpdate" type="text" size="small" @click="updateModal(scope.row)">修改</a>
  87. <a v-if="!authDelete" type="text" size="small" @click="deleteModal(scope.row)">删除</a>
  88. </template>
  89. </el-table-column>
  90. </el-table>
  91. <el-pagination
  92. @size-change="sizeChangeHandle"
  93. @current-change="currentChangeHandle"
  94. :current-page="pageIndex"
  95. :page-sizes="[20, 50, 100, 200, 500]"
  96. :page-size="pageSize"
  97. :total="totalPage"
  98. layout="total, sizes, prev, pager, next, jumper">
  99. </el-pagination>
  100. <!-- 新增和修改 -->
  101. <el-dialog title="检验方法" :close-on-click-modal="false" v-drag :visible.sync="modalFlag" width="500px">
  102. <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
  103. <el-form-item label="BU" prop="bu" :rules="rules.bu">
  104. <el-select v-model="modalData.bu" placeholder="请选择" :disabled="modalDisableFlag" style="width: 456px">
  105. <el-option
  106. v-for="i in userBuList"
  107. :key="i.buNo"
  108. :label="i.sitename"
  109. :value="i.buNo">
  110. <span style="float: left;width: 100px">{{ i.sitename }}</span>
  111. <span style="float: right; color: #8492a6;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; font-size: 11px;width: 60px">
  112. {{ i.buDesc }}
  113. </span>
  114. </el-option>
  115. </el-select>
  116. </el-form-item>
  117. </el-form>
  118. <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
  119. <el-form-item label="方法名称:" prop="methodName" :rules="rules.methodNameType">
  120. <el-input v-model="modalData.methodName" style="width: 221px"></el-input>
  121. </el-form-item>
  122. <el-form-item label="检验类型:" prop="inspectionTypeNo" :rules="rules.inspectionTypeNoType">
  123. <el-select v-model="modalData.inspectionTypeNo" placeholder="请选择" style="width: 221px">
  124. <el-option
  125. v-for="i in options"
  126. :key="i.inspectionTypeNo"
  127. :label="i.inspectionTypeName"
  128. :value="i.inspectionTypeNo">
  129. </el-option>
  130. </el-select>
  131. </el-form-item>
  132. </el-form>
  133. <el-form :inline="true" label-position="top" :model="modalData" style="margin-left: 7px;margin-top: -5px;">
  134. <el-form-item :label="'检验方法说明:'">
  135. <el-input v-model="modalData.methodRemark" style="width: 456px"></el-input>
  136. </el-form-item>
  137. </el-form>
  138. <el-footer style="height:40px;margin-top: 20px;text-align:center">
  139. <el-button type="primary" @click="saveData()">保存</el-button>
  140. <el-button type="primary" @click="modalFlag = false">关闭</el-button>
  141. </el-footer>
  142. </el-dialog>
  143. </div>
  144. </template>
  145. <script>
  146. // 请求体/响应字段与后端 DmMethodData 一致;删除前服务端检查 dm_method_item(DmMethodItemData)
  147. import {
  148. qcMethodSearch,
  149. dmMethodSave,
  150. dmMethodUpdate,
  151. dmMethodDelete,
  152. inspectionTypeSearch,
  153. getSiteAndBuByUserName
  154. } from "@/api/qc/dmBasic.js";
  155. import { getTableDefaultListLanguage, getTableUserListLanguage, updateColumnSize } from "@/api/table.js";
  156. import { userFavoriteList, saveUserFavorite, removeUserFavorite } from "@/api/userFavorite.js";
  157. export default {
  158. name: "DMQcMethod",
  159. data() {
  160. return {
  161. columnsProp: ["createBy", "updateBy"],
  162. favorite: false,
  163. exportData: [],
  164. exportName: "刀模检验方法" + this.dayjs().format("YYYYMMDDHHmmss"),
  165. exportHeader: ["刀模检验方法"],
  166. exportFooter: [],
  167. exportList: [],
  168. searchData: {
  169. site: "",
  170. userName: this.$store.state.user.name,
  171. methodNo: "",
  172. methodName: "",
  173. inspectionTypeNo: "",
  174. buDesc: "RFID",
  175. page: 1,
  176. limit: 10
  177. },
  178. pageIndex: 1,
  179. pageSize: 20,
  180. totalPage: 0,
  181. height: 200,
  182. dataList: [],
  183. dataListLoading: false,
  184. modalFlag: false,
  185. modalDisableFlag: false,
  186. modalData: {
  187. site: this.$store.state.user.site,
  188. bu: "2_03-RFID",
  189. flag: "",
  190. methodNo: "",
  191. methodName: "",
  192. createBy: this.$store.state.user.name,
  193. updateBy: this.$store.state.user.name,
  194. methodRemark: "",
  195. inspectionTypeNo: "823"
  196. },
  197. columnList: [
  198. {
  199. userId: this.$store.state.user.name,
  200. functionId: 822001,
  201. serialNumber: "822001TableBuDesc",
  202. tableId: "822001Table",
  203. tableName: "检验方法维护表",
  204. columnProp: "buDesc",
  205. headerAlign: "center",
  206. align: "center",
  207. columnLabel: "BU",
  208. columnHidden: false,
  209. columnImage: false,
  210. columnSortable: false,
  211. sortLv: 0,
  212. status: true,
  213. fixed: "",
  214. columnWidth: 100
  215. },
  216. {
  217. userId: this.$store.state.user.name,
  218. functionId: 822001,
  219. serialNumber: "822001TableMethodNo",
  220. tableId: "822001Table",
  221. tableName: "检验方法维护表",
  222. columnProp: "methodNo",
  223. headerAlign: "center",
  224. align: "center",
  225. columnLabel: "方法编码",
  226. columnHidden: false,
  227. columnImage: false,
  228. columnSortable: false,
  229. sortLv: 0,
  230. status: true,
  231. fixed: "",
  232. columnWidth: 120
  233. },
  234. {
  235. userId: this.$store.state.user.name,
  236. functionId: 822001,
  237. serialNumber: "822001TableMethodName",
  238. tableId: "822001Table",
  239. tableName: "检验方法维护表",
  240. columnProp: "methodName",
  241. headerAlign: "center",
  242. align: "left",
  243. columnLabel: "方法名称",
  244. columnHidden: false,
  245. columnImage: false,
  246. columnSortable: false,
  247. sortLv: 0,
  248. status: true,
  249. fixed: "",
  250. columnWidth: 200
  251. },
  252. {
  253. userId: this.$store.state.user.name,
  254. functionId: 822001,
  255. serialNumber: "822001TableMethodRemark",
  256. tableId: "822001Table",
  257. tableName: "检验方法维护表",
  258. columnProp: "methodRemark",
  259. headerAlign: "center",
  260. align: "left",
  261. columnLabel: "方法说明",
  262. columnHidden: false,
  263. columnImage: false,
  264. columnSortable: false,
  265. sortLv: 0,
  266. status: true,
  267. fixed: "",
  268. columnWidth: 200
  269. },
  270. {
  271. userId: this.$store.state.user.name,
  272. functionId: 822001,
  273. serialNumber: "822001TableInspectionTypeName",
  274. tableId: "822001Table",
  275. tableName: "检验方法维护表",
  276. columnProp: "inspectionTypeName",
  277. headerAlign: "center",
  278. align: "center",
  279. columnLabel: "检验类型",
  280. columnHidden: false,
  281. columnImage: false,
  282. columnSortable: false,
  283. sortLv: 0,
  284. status: true,
  285. fixed: "",
  286. columnWidth: 120
  287. },
  288. {
  289. userId: this.$store.state.user.name,
  290. functionId: 822001,
  291. serialNumber: "822001TableCreateDate",
  292. tableId: "822001Table",
  293. tableName: "检验方法维护表",
  294. columnProp: "createDate",
  295. headerAlign: "center",
  296. align: "center",
  297. columnLabel: "创建时间",
  298. columnHidden: false,
  299. columnImage: false,
  300. columnSortable: false,
  301. sortLv: 0,
  302. status: true,
  303. fixed: "",
  304. columnWidth: 170
  305. },
  306. {
  307. userId: this.$store.state.user.name,
  308. functionId: 822001,
  309. serialNumber: "822001TableCreateBy",
  310. tableId: "822001Table",
  311. tableName: "检验方法维护表",
  312. columnProp: "createBy",
  313. headerAlign: "center",
  314. align: "center",
  315. columnLabel: "创建人",
  316. columnHidden: false,
  317. columnImage: false,
  318. columnSortable: false,
  319. sortLv: 0,
  320. status: true,
  321. fixed: "",
  322. columnWidth: 120
  323. },
  324. {
  325. userId: this.$store.state.user.name,
  326. functionId: 822001,
  327. serialNumber: "822001TableUpdateDate",
  328. tableId: "822001Table",
  329. tableName: "检验方法维护表",
  330. columnProp: "updateDate",
  331. headerAlign: "center",
  332. align: "center",
  333. columnLabel: "更新时间",
  334. columnHidden: false,
  335. columnImage: false,
  336. columnSortable: false,
  337. sortLv: 0,
  338. status: true,
  339. fixed: "",
  340. columnWidth: 170
  341. },
  342. {
  343. userId: this.$store.state.user.name,
  344. functionId: 822001,
  345. serialNumber: "822001TableUpdateBy",
  346. tableId: "822001Table",
  347. tableName: "检验方法维护表",
  348. columnProp: "updateBy",
  349. headerAlign: "center",
  350. align: "center",
  351. columnLabel: "更新人",
  352. columnHidden: false,
  353. columnImage: false,
  354. columnSortable: false,
  355. sortLv: 0,
  356. status: true,
  357. fixed: "",
  358. columnWidth: 120
  359. }
  360. ],
  361. rules: {
  362. methodNameType: [{ required: true, message: " ", trigger: ["blur", "change"] }],
  363. inspectionTypeNoType: [{ required: true, message: " ", trigger: ["blur", "change"] }],
  364. bu: [{ required: true, message: " ", trigger: ["blur", "change"] }]
  365. },
  366. options: [],
  367. userBuList: [],
  368. authSearch: false,
  369. authSave: false,
  370. authUpdate: false,
  371. authDelete: false,
  372. menuId: this.$route.meta.menuId
  373. };
  374. },
  375. mounted() {
  376. this.$nextTick(() => {
  377. this.height = window.innerHeight - 180;
  378. });
  379. },
  380. created() {
  381. this.getButtonAuthData();
  382. this.getSiteAndBuByUserName();
  383. this.favoriteIsOk();
  384. this.inspectionTypeSearch();
  385. this.getTableUserColumn(this.$route.meta.menuId + "table", 1);
  386. if (!this.authSearch) {
  387. this.getDataList();
  388. }
  389. },
  390. methods: {
  391. handleColumnResize(newWidth, oldWidth, column) {
  392. const inData = this.columnList.filter(item => item.columnProp === column.property)[0];
  393. inData.columnWidth = newWidth;
  394. updateColumnSize(inData).then(({ data }) => {
  395. if (data.code === 0) {
  396. console.log("栏位宽度保存成功!");
  397. }
  398. });
  399. },
  400. getSiteAndBuByUserName() {
  401. const tempData = { username: this.$store.state.user.name };
  402. getSiteAndBuByUserName(tempData).then(({ data }) => {
  403. if (data.code === 0) {
  404. this.userBuList = data.rows;
  405. }
  406. });
  407. },
  408. getDataList() {
  409. this.searchData.limit = this.pageSize;
  410. this.searchData.page = this.pageIndex;
  411. qcMethodSearch(this.searchData).then(({ data }) => {
  412. if (data.code === 0) {
  413. this.dataList = data.page.list;
  414. this.pageIndex = data.page.currPage;
  415. this.pageSize = data.page.pageSize;
  416. this.totalPage = data.page.totalCount;
  417. }
  418. });
  419. },
  420. sizeChangeHandle(val) {
  421. this.pageSize = val;
  422. this.pageIndex = 1;
  423. this.getDataList();
  424. },
  425. currentChangeHandle(val) {
  426. this.pageIndex = val;
  427. this.getDataList();
  428. },
  429. addModal() {
  430. this.modalData = {
  431. flag: "1",
  432. site: this.$store.state.user.site,
  433. bu: '2_03-RFID',
  434. createBy: this.$store.state.user.name,
  435. updateBy: this.$store.state.user.name,
  436. methodNo: "",
  437. methodName: "",
  438. methodRemark: "",
  439. inspectionTypeNo: "823"
  440. };
  441. this.modalDisableFlag = false;
  442. this.modalFlag = true;
  443. },
  444. updateModal(row) {
  445. this.modalData = {
  446. flag: "2",
  447. bu: row.site + "_" + row.buNo,
  448. site: row.site,
  449. createBy: this.$store.state.user.name,
  450. updateBy: this.$store.state.user.name,
  451. methodNo: row.methodNo,
  452. methodName: row.methodName,
  453. methodRemark: row.methodRemark,
  454. inspectionTypeNo: row.inspectionTypeNo
  455. };
  456. this.modalDisableFlag = true;
  457. this.modalFlag = true;
  458. },
  459. deleteModal(row) {
  460. this.$confirm(`是否删除这个检验方法?`, "提示", {
  461. confirmButtonText: "确定",
  462. cancelButtonText: "取消",
  463. type: "warning"
  464. })
  465. .then(() => {
  466. dmMethodDelete(row).then(({ data }) => {
  467. if (data && data.code === 0) {
  468. this.getDataList();
  469. this.$message({ message: "操作成功", type: "success", duration: 1500, onClose: () => {} });
  470. } else {
  471. this.$alert(data.msg, "错误", { confirmButtonText: "确定" });
  472. }
  473. });
  474. })
  475. .catch(() => {});
  476. },
  477. saveData() {
  478. if (this.modalData.bu === "" || this.modalData.bu == null) {
  479. this.$message.warning("请选择BU!");
  480. return;
  481. }
  482. if (this.modalData.methodName === "" || this.modalData.methodName == null) {
  483. this.$message.warning("请输入检验方法名称!");
  484. return;
  485. }
  486. if (this.modalData.flag === "1") {
  487. dmMethodSave(this.modalData).then(({ data }) => {
  488. if (data && data.code === 0) {
  489. this.getDataList();
  490. this.modalFlag = false;
  491. this.$message({ message: "操作成功", type: "success", duration: 1500, onClose: () => {} });
  492. } else {
  493. this.$alert(data.msg, "错误", { confirmButtonText: "确定" });
  494. }
  495. });
  496. } else {
  497. dmMethodUpdate(this.modalData).then(({ data }) => {
  498. if (data && data.code === 0) {
  499. this.getDataList();
  500. this.modalFlag = false;
  501. this.$message({ message: "操作成功", type: "success", duration: 1500, onClose: () => {} });
  502. } else {
  503. this.$alert(data.msg, "错误", { confirmButtonText: "确定" });
  504. }
  505. });
  506. }
  507. },
  508. inspectionTypeSearch() {
  509. const tempData = { site: this.$store.state.user.site };
  510. inspectionTypeSearch(tempData).then(({ data }) => {
  511. if (data.code === 0) {
  512. this.options = data.rows;
  513. this.modalData.inspectionTypeNo = "823";
  514. }
  515. });
  516. },
  517. favoriteIsOk() {
  518. const userFavorite = { userId: this.$store.state.user.id, languageCode: this.$i18n.locale };
  519. userFavoriteList(userFavorite).then(({ data }) => {
  520. for (let i = 0; i < data.list.length; i++) {
  521. if (this.$route.meta.menuId === data.list[i].menuId) {
  522. this.favorite = true;
  523. }
  524. }
  525. });
  526. },
  527. favoriteFunction() {
  528. const userFavorite = { userId: this.$store.state.user.id, functionId: this.$route.meta.menuId };
  529. if (this.favorite) {
  530. removeUserFavorite(userFavorite).then(({ data }) => {
  531. this.$message.success(data.msg);
  532. this.favorite = false;
  533. });
  534. } else {
  535. saveUserFavorite(userFavorite).then(({ data }) => {
  536. this.$message.success(data.msg);
  537. this.favorite = true;
  538. });
  539. }
  540. },
  541. async createExportData() {
  542. this.searchData.limit = -1;
  543. this.searchData.page = 1;
  544. this.searchData.inspectionTypeNo = "823";
  545. await qcMethodSearch(this.searchData).then(({ data }) => {
  546. this.exportList = data.page.list;
  547. });
  548. return this.exportList;
  549. },
  550. startDownload() {},
  551. finishDownload() {},
  552. fields() {
  553. let json = "{";
  554. this.columnList.forEach((item, index) => {
  555. if (index === this.columnList.length - 1) {
  556. json += '"' + item.columnLabel + '":"' + item.columnProp + '"';
  557. } else {
  558. json += '"' + item.columnLabel + '":"' + item.columnProp + '",';
  559. }
  560. });
  561. json += "}";
  562. // eslint-disable-next-line no-eval
  563. return eval("(" + json + ")");
  564. },
  565. async getTableUserColumn(tableId, columnId) {
  566. const queryTableUser = {
  567. userId: this.$store.state.user.name,
  568. functionId: this.$route.meta.menuId,
  569. tableId,
  570. status: true,
  571. languageCode: this.$i18n.locale
  572. };
  573. await getTableUserListLanguage(queryTableUser).then(({ data }) => {
  574. if (data.rows.length > 0) {
  575. if (columnId === 1) this.columnList = data.rows;
  576. } else {
  577. this.getColumnList(tableId, columnId);
  578. }
  579. });
  580. },
  581. async getColumnList(tableId, columnId) {
  582. const queryTable = { functionId: this.$route.meta.menuId, tableId, languageCode: this.$i18n.locale };
  583. await getTableDefaultListLanguage(queryTable).then(({ data }) => {
  584. if (!data.rows.length === 0) {
  585. if (columnId === 1) this.columnList = data.rows;
  586. }
  587. });
  588. },
  589. getButtonAuthData() {
  590. const searchFlag = this.isAuth(this.menuId + ":search");
  591. const saveFlag = this.isAuth(this.menuId + ":save");
  592. const updateFlag = this.isAuth(this.menuId + ":update");
  593. const deleteFlag = this.isAuth(this.menuId + ":delete");
  594. this.authSearch = !searchFlag;
  595. this.authSave = !saveFlag;
  596. this.authUpdate = !updateFlag;
  597. this.authDelete = !deleteFlag;
  598. }
  599. }
  600. };
  601. </script>
  602. <style scoped>
  603. .el-table /deep/ .cell{
  604. height: auto;
  605. line-height: 1.5;
  606. }
  607. </style>