祥兆质量前端
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.

960 lines
31 KiB

2 years ago
  1. <template>
  2. <div class="mod-config">
  3. <!-- 收藏 -->
  4. <div>
  5. <span @click="favoriteFunction()">
  6. <icon-svg :name="favorite?'xiangqufill':'xiangqu'" class="sl-svg"></icon-svg>
  7. </span>
  8. </div>
  9. <!-- 条件查询 -->
  10. <el-form :inline="true" label-position="top" :model="searchData" @keyup.enter.native="getDataList()">
  11. <el-form-item :label="'BU'">
  12. <el-select v-model="searchData.buDesc" placeholder="请选择" clearable style="width: 130px">
  13. <el-option
  14. v-for = "i in userBuList"
  15. :key = "i.buNo"
  16. :label = "i.buDesc"
  17. :value = "i.buDesc">
  18. </el-option>
  19. </el-select>
  20. </el-form-item>
  21. <el-form-item :label="'检验水平'">
  22. <el-input v-model="searchData.samplingLevelDesc" clearable style="width: 120px"></el-input>
  23. </el-form-item>
  24. <el-form-item :label="'样本量字码'">
  25. <el-input v-model="searchData.samplingQtyDesc" clearable style="width: 120px"></el-input>
  26. </el-form-item>
  27. <el-form-item :label="'是否可用'">
  28. <el-select v-model="searchData.samplingPlanActive" style="width: 130px">
  29. <el-option label="全部" value=""></el-option>
  30. <el-option label="是" value="Y"></el-option>
  31. <el-option label="否" value="N"></el-option>
  32. </el-select>
  33. </el-form-item>
  34. <el-form-item :label="' '">
  35. <!-- <el-button @click="doEmpty()">清空</el-button>-->
  36. <el-button v-if="!authSearch" type="primary" @click="getDataList()">查询</el-button>
  37. <el-button v-if="!authSave" type="primary" @click="addModal()">新增</el-button>
  38. <download-excel
  39. :fields="fields()"
  40. :data="exportData"
  41. type="xls"
  42. :name="exportName"
  43. :header="exportHeader"
  44. :footer="exportFooter"
  45. :fetch="createExportData"
  46. :before-generate="startDownload"
  47. :before-finish="finishDownload"
  48. worksheet="导出信息"
  49. class="el-button el-button--primary el-button--medium">
  50. {{ "导出" }}
  51. </download-excel>
  52. </el-form-item>
  53. </el-form>
  54. <!-- 展示列表 -->
  55. <el-table
  56. :height="height"
  57. :data="dataList"
  58. border
  59. style="width: 100%;">
  60. <el-table-column
  61. v-for="(item,index) in columnList" :key="index"
  62. :sortable="item.columnSortable"
  63. :prop="item.columnProp"
  64. :header-align="item.headerAlign"
  65. :show-overflow-tooltip="item.showOverflowTooltip"
  66. :align="item.align"
  67. :fixed="item.fixed === ''?false:item.fixed"
  68. :min-width="item.columnWidth"
  69. :label="item.columnLabel">
  70. <template slot-scope="scope">
  71. <span v-if="!item.columnHidden">{{scope.row[item.columnProp]}}</span>
  72. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
  73. </template>
  74. </el-table-column>
  75. <el-table-column
  76. fixed="right"
  77. header-align="center"
  78. align="center"
  79. width="160"
  80. label="操作">
  81. <template slot-scope="scope">
  82. <a v-if="!authUpdate" type="text" size="small" @click="updateModal(scope.row)">编辑</a>
  83. <a v-if="!authDelete" type="text" size="small" @click="deleteModal(scope.row)">删除</a>
  84. </template>
  85. </el-table-column>
  86. </el-table>
  87. <!-- 分页-->
  88. <el-pagination
  89. @size-change="sizeChangeHandle"
  90. @current-change="currentChangeHandle"
  91. :current-page="pageIndex"
  92. :page-sizes="[20, 50, 100, 200, 500]"
  93. :page-size="pageSize"
  94. :total="totalPage"
  95. layout="total, sizes, prev, pager, next, jumper">
  96. </el-pagination>
  97. <!-- 新增和修改 -->
  98. <el-dialog title="样本量字码矩阵" :close-on-click-modal="false" v-drag :visible.sync="modalFlag" width="500px">
  99. <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
  100. <el-form-item label="BU" prop="bu" :rules="rules.bu">
  101. <el-select v-model="modalData.bu" placeholder="请选择" :disabled="modalDisableFlag" style="width: 456px">
  102. <el-option
  103. v-for = "i in userBuList"
  104. :key = "i.buNo"
  105. :label = "i.buNo"
  106. :value = "i.buNo">
  107. <span style="float: left;width: 100px">{{ i.sitename }}</span>
  108. <span style="float: right; color: #8492a6;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; font-size: 11px;width: 60px">
  109. {{ i.buDesc }}
  110. </span>
  111. </el-option>
  112. </el-select>
  113. </el-form-item>
  114. </el-form>
  115. <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
  116. <el-form-item label="矩阵名称:" prop="samplingPlanDesc" :rules="rules.samplingPlanDescType">
  117. <el-input v-model="modalData.samplingPlanDesc" style="width: 221px"></el-input>
  118. </el-form-item>
  119. <el-form-item label="是否在用:" prop="samplingPlanActive" :rules="rules.samplingPlanActiveType">
  120. <el-select filterable v-model="modalData.samplingPlanActive" style="width: 221px">
  121. <el-option label="是" value="Y"></el-option>
  122. <el-option label="否" value="N"></el-option>
  123. </el-select>
  124. </el-form-item>
  125. </el-form>
  126. <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
  127. <el-form-item prop="samplingQtyNo" :rules="rules.samplingQtyNoType">
  128. <span slot="label" style="" @click="getBaseList(210)"><a herf="#">样本量编码</a></span>
  129. <el-input v-model="modalData.samplingQtyNo" style="width: 221px"></el-input>
  130. </el-form-item>
  131. <el-form-item label="样本量字码:" prop="samplingQtyDesc" :rules="rules.samplingQtyDescType">
  132. <el-input v-model="modalData.samplingQtyDesc" disabled style="width: 221px"></el-input>
  133. </el-form-item>
  134. </el-form>
  135. <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
  136. <el-form-item prop="samplingQtyRankNo" :rules="rules.samplingQtyRankNoType">
  137. <span slot="label" style="" @click="getBaseList(209)"><a herf="#">抽样量级别编码</a></span>
  138. <el-input v-model="modalData.samplingQtyRankNo" style="width: 221px"></el-input>
  139. </el-form-item>
  140. <el-form-item label="抽样量级别名称:" prop="samplingQtyRankDesc" :rules="rules.samplingQtyRankDescType">
  141. <el-input v-model="modalData.samplingQtyRankDesc" disabled style="width: 221px"></el-input>
  142. </el-form-item>
  143. </el-form>
  144. <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
  145. <el-form-item prop="samplingLevelNo" :rules="rules.samplingLevelNoType">
  146. <span slot="label" style="" @click="getBaseList(208)"><a herf="#">抽样等级编码</a></span>
  147. <el-input v-model="modalData.samplingLevelNo" style="width: 221px"></el-input>
  148. </el-form-item>
  149. <el-form-item label="抽样等级名称:" prop="samplingLevelDesc" :rules="rules.samplingLevelDescType">
  150. <el-input v-model="modalData.samplingLevelDesc" disabled style="width: 221px"></el-input>
  151. </el-form-item>
  152. </el-form>
  153. <el-footer style="height:40px;margin-top: 20px;text-align:center">
  154. <el-button type="primary" @click="saveData()">保存</el-button>
  155. <el-button type="primary" @click="modalFlag = false">关闭</el-button>
  156. </el-footer>
  157. </el-dialog>
  158. <Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist>
  159. </div>
  160. </template>
  161. <script>
  162. import {
  163. samplingInspectionPlanSearch, // 查询矩阵
  164. samplingInspectionPlanSave, // 新增矩阵
  165. samplingInspectionPlanUpdate, // 修改矩阵
  166. samplingInspectionPlanDelete, // 删除矩阵
  167. getSiteAndBuByUserName
  168. } from "@/api/qc/qc.js"
  169. import {getTableDefaultListLanguage, getTableUserListLanguage} from "@/api/table.js"
  170. import Chooselist from '@/views/modules/common/Chooselist_eam'
  171. import {userFavoriteList, saveUserFavorite, removeUserFavorite} from '@/api/userFavorite.js'
  172. export default {
  173. components: {
  174. Chooselist
  175. },
  176. watch: {
  177. modalData: {
  178. deep: true,
  179. handler: function (newV, oldV) {
  180. this.modalData.samplingPlanNo = this.modalData.samplingPlanNo.toUpperCase()
  181. }
  182. }
  183. },
  184. data () {
  185. return {
  186. // 是否收藏
  187. favorite: false,
  188. // 导出 start
  189. exportData: [],
  190. exportName: "检验项目" + this.dayjs().format('YYYYMMDDHHmmss'),
  191. exportHeader: ["检验项目"],
  192. exportFooter: [],
  193. exportList: [],
  194. // 导出 end
  195. // 条件查询对象
  196. searchData: {
  197. site: '',
  198. userName: this.$store.state.user.name,
  199. samplingLevelDesc: '',
  200. samplingQtyDesc: '',
  201. samplingPlanActive: '',
  202. buDesc: '',
  203. page: 1,
  204. limit: 10,
  205. },
  206. // 分页对象
  207. pageIndex: 1,
  208. pageSize: 20,
  209. totalPage: 0,
  210. height: 200,
  211. dataList: [],
  212. dataListSelections: [],
  213. // 其它对象
  214. modalFlag: false,
  215. modalDisableFlag: false,
  216. modalData: {
  217. flag: '',
  218. site: '',
  219. bu: '',
  220. samplingPlanNo: '',
  221. samplingPlanDesc: '',
  222. samplingQtyNo: '',
  223. samplingQty: '',
  224. samplingQtyDesc: '',
  225. samplingQtyRankDesc: '',
  226. samplingQtyRankNo: '',
  227. minQty: '',
  228. maxQty: '',
  229. samplingLevelNo: '',
  230. samplingLevelDesc: '',
  231. samplingPlanActive: '',
  232. createBy: this.$store.state.user.name,
  233. updateBy: this.$store.state.user.name
  234. },
  235. detailData: {
  236. id: '',
  237. site: '',
  238. buNo: '',
  239. samplingQtyRankNo: '',
  240. samplingQtyRankDesc: '',
  241. samplingLevelNo: '',
  242. samplingLevelDesc: '',
  243. samplingQtyNo: '',
  244. samplingQty: '',
  245. samplingPlanActive: ''
  246. },
  247. // 展示标头
  248. columnList: [
  249. {
  250. userId: this.$store.state.user.name,
  251. functionId: 301012,
  252. serialNumber: '301012TableBuDesc',
  253. tableId: "301012Table",
  254. tableName: "样本量字码矩阵表",
  255. columnWidth: 100,
  256. columnProp: 'buDesc',
  257. headerAlign: 'center',
  258. align: "center",
  259. columnLabel: 'BU',
  260. columnHidden: false,
  261. columnImage: false,
  262. columnSortable: false,
  263. sortLv: 0,
  264. status: true,
  265. fixed: '',
  266. },
  267. {
  268. userId: this.$store.state.user.name,
  269. functionId: 301012,
  270. serialNumber: '301012TableSamplingPlanNo',
  271. tableId: "301012Table",
  272. tableName: "样本量字码矩阵表",
  273. columnWidth: 122,
  274. columnProp: 'samplingPlanNo',
  275. headerAlign: 'center',
  276. align: "center",
  277. columnLabel: '矩阵编码',
  278. columnHidden: false,
  279. columnImage: false,
  280. columnSortable: false,
  281. sortLv: 0,
  282. status: true,
  283. fixed: '',
  284. },
  285. {
  286. userId: this.$store.state.user.name,
  287. functionId: 301012,
  288. serialNumber: '301012TableSamplingPlanDesc',
  289. tableId: "301012Table",
  290. tableName: "样本量字码矩阵表",
  291. columnWidth: 110,
  292. columnProp: 'samplingPlanDesc',
  293. headerAlign: 'center',
  294. align: "center",
  295. columnLabel: '矩阵名称',
  296. columnHidden: false,
  297. columnImage: false,
  298. columnSortable: false,
  299. sortLv: 0,
  300. status: true,
  301. fixed: '',
  302. },
  303. {
  304. userId: this.$store.state.user.name,
  305. functionId: 301012,
  306. serialNumber: '301012TableSamplingQtyDesc',
  307. tableId: "301012Table",
  308. tableName: "样本量字码矩阵表",
  309. columnWidth: 110,
  310. columnProp: 'samplingQtyDesc',
  311. headerAlign: 'center',
  312. align: "center",
  313. columnLabel: '样本量字码',
  314. columnHidden: false,
  315. columnImage: false,
  316. columnSortable: false,
  317. sortLv: 0,
  318. status: true,
  319. fixed: '',
  320. },
  321. {
  322. userId: this.$store.state.user.name,
  323. functionId: 301012,
  324. serialNumber: '301012TableSamplingQty',
  325. tableId: "301012Table",
  326. tableName: "样本量字码矩阵表",
  327. columnWidth: 110,
  328. columnProp: 'samplingQty',
  329. headerAlign: 'center',
  330. align: "right",
  331. columnLabel: '样本量',
  332. columnHidden: false,
  333. columnImage: false,
  334. columnSortable: false,
  335. sortLv: 0,
  336. status: true,
  337. fixed: '',
  338. },
  339. {
  340. userId: this.$store.state.user.name,
  341. functionId: 301012,
  342. serialNumber: '301012TableSamplingQtyRankDesc',
  343. tableId: "301012Table",
  344. tableName: "样本量字码矩阵表",
  345. columnWidth: 110,
  346. columnProp: 'samplingQtyRankDesc',
  347. headerAlign: 'center',
  348. align: "center",
  349. columnLabel: '批量级次',
  350. columnHidden: false,
  351. columnImage: false,
  352. columnSortable: false,
  353. sortLv: 0,
  354. status: true,
  355. fixed: '',
  356. },
  357. {
  358. userId: this.$store.state.user.name,
  359. functionId: 301012,
  360. serialNumber: '301012TableMinQty',
  361. tableId: "301012Table",
  362. tableName: "样本量字码矩阵表",
  363. columnWidth: 110,
  364. columnProp: 'minQty',
  365. headerAlign: 'center',
  366. align: "right",
  367. columnLabel: '最小抽样数',
  368. columnHidden: false,
  369. columnImage: false,
  370. columnSortable: false,
  371. sortLv: 0,
  372. status: true,
  373. fixed: '',
  374. },
  375. {
  376. userId: this.$store.state.user.name,
  377. functionId: 301012,
  378. serialNumber: '301012TableMaxQty',
  379. tableId: "301012Table",
  380. tableName: "样本量字码矩阵表",
  381. columnWidth: 110,
  382. columnProp: 'maxQty',
  383. headerAlign: 'center',
  384. align: "right",
  385. columnLabel: '最大抽样数',
  386. columnHidden: false,
  387. columnImage: false,
  388. columnSortable: false,
  389. sortLv: 0,
  390. status: true,
  391. fixed: '',
  392. },
  393. {
  394. userId: this.$store.state.user.name,
  395. functionId: 301012,
  396. serialNumber: '301012TableSamplingLevelDesc',
  397. tableId: "301012Table",
  398. tableName: "样本量字码矩阵表",
  399. columnWidth: 110,
  400. columnProp: 'samplingLevelDesc',
  401. headerAlign: 'center',
  402. align: "center",
  403. columnLabel: '抽样等级',
  404. columnHidden: false,
  405. columnImage: false,
  406. columnSortable: false,
  407. sortLv: 0,
  408. status: true,
  409. fixed: '',
  410. },
  411. {
  412. userId: this.$store.state.user.name,
  413. functionId: 301012,
  414. serialNumber: '301012TableSamplingPlanActive',
  415. tableId: "301012Table",
  416. tableName: "样本量字码矩阵表",
  417. columnWidth: 110,
  418. columnProp: 'samplingPlanActive',
  419. headerAlign: 'center',
  420. align: "center",
  421. columnLabel: '是否可用',
  422. columnHidden: false,
  423. columnImage: false,
  424. columnSortable: false,
  425. sortLv: 0,
  426. status: true,
  427. fixed: '',
  428. },
  429. {
  430. userId: this.$store.state.user.name,
  431. functionId: 301012,
  432. serialNumber: '301012TableCreateDate',
  433. tableId: "301012Table",
  434. tableName: "样本量字码矩阵表",
  435. columnWidth: 110,
  436. columnProp: 'createDate',
  437. headerAlign: 'center',
  438. align: "center",
  439. columnLabel: '创建时间',
  440. columnHidden: false,
  441. columnImage: false,
  442. columnSortable: false,
  443. sortLv: 0,
  444. status: true,
  445. fixed: '',
  446. },
  447. {
  448. userId: this.$store.state.user.name,
  449. functionId: 301012,
  450. serialNumber: '301012TableCreateBy',
  451. tableId: "301012Table",
  452. tableName: "样本量字码矩阵表",
  453. columnWidth: 110,
  454. columnProp: 'createBy',
  455. headerAlign: 'center',
  456. align: "center",
  457. columnLabel: '创建人',
  458. columnHidden: false,
  459. columnImage: false,
  460. columnSortable: false,
  461. sortLv: 0,
  462. status: true,
  463. fixed: '',
  464. },
  465. {
  466. userId: this.$store.state.user.name,
  467. functionId: 301012,
  468. serialNumber: '301012TableUpdateDate',
  469. tableId: "301012Table",
  470. tableName: "样本量字码矩阵表",
  471. columnWidth: 110,
  472. columnProp: 'updateDate',
  473. headerAlign: 'center',
  474. align: "center",
  475. columnLabel: '更新时间',
  476. columnHidden: false,
  477. columnImage: false,
  478. columnSortable: false,
  479. sortLv: 0,
  480. status: true,
  481. fixed: '',
  482. },
  483. {
  484. userId: this.$store.state.user.name,
  485. functionId: 301012,
  486. serialNumber: '301012TableUpdateBy',
  487. tableId: "301012Table",
  488. tableName: "样本量字码矩阵表",
  489. columnWidth: 110,
  490. columnProp: 'updateBy',
  491. headerAlign: 'center',
  492. align: "center",
  493. columnLabel: '更新人',
  494. columnHidden: false,
  495. columnImage: false,
  496. columnSortable: false,
  497. sortLv: 0,
  498. status: true,
  499. fixed: '',
  500. },
  501. ],
  502. rules: {
  503. samplingPlanDescType:[
  504. {
  505. required: true,
  506. message: ' ',
  507. trigger: ['blur','change']
  508. }
  509. ],
  510. samplingPlanActiveType:[
  511. {
  512. required: true,
  513. message: ' ',
  514. trigger: ['blur','change']
  515. }
  516. ],
  517. samplingQtyNoType:[
  518. {
  519. required: true,
  520. message: ' ',
  521. trigger: ['blur','change']
  522. }
  523. ],
  524. samplingQtyDescType:[
  525. {
  526. required: true,
  527. message: ' ',
  528. trigger: ['blur','change']
  529. }
  530. ],
  531. samplingQtyRankNoType:[
  532. {
  533. required: true,
  534. message: ' ',
  535. trigger: ['blur','change']
  536. }
  537. ],
  538. samplingQtyRankDescType:[
  539. {
  540. required: true,
  541. message: ' ',
  542. trigger: ['blur','change']
  543. }
  544. ],
  545. samplingLevelNoType:[
  546. {
  547. required: true,
  548. message: ' ',
  549. trigger: ['blur','change']
  550. }
  551. ],
  552. samplingLevelDescType:[
  553. {
  554. required: true,
  555. message: ' ',
  556. trigger: ['blur','change']
  557. }
  558. ],
  559. bu:[
  560. {
  561. required: true,
  562. message: ' ',
  563. trigger: ['blur','change']
  564. }
  565. ]
  566. },
  567. userBuList: [],
  568. authSearch: false,
  569. authSave: false,
  570. authUpdate: false,
  571. authDelete: false,
  572. menuId: this.$route.meta.menuId,
  573. }
  574. },
  575. mounted () {
  576. this.$nextTick(() => {
  577. this.height = window.innerHeight - 180
  578. })
  579. },
  580. created () {
  581. // 按钮控制
  582. this.getButtonAuthData()
  583. // 获取用户的 site 和 bu
  584. this.getSiteAndBuByUserName()
  585. // 校验用户是否收藏
  586. this.favoriteIsOk()
  587. // 动态列
  588. this.getTableUserColumn(this.$route.meta.menuId+'table',1)
  589. if (!this.authSearch) {
  590. // 获取数据列表
  591. this.getDataList()
  592. }
  593. },
  594. methods: {
  595. // 获取用户的bu
  596. getSiteAndBuByUserName () {
  597. let tempData = {
  598. username: this.$store.state.user.name,
  599. }
  600. getSiteAndBuByUserName(tempData).then(({data}) => {
  601. if (data.code === 0) {
  602. this.userBuList = data.rows
  603. }
  604. })
  605. },
  606. // 获取数据列表
  607. getDataList () {
  608. this.searchData.limit = this.pageSize
  609. this.searchData.page = this.pageIndex
  610. samplingInspectionPlanSearch(this.searchData).then(({data}) => {
  611. if (data.code === 0) {
  612. this.dataList = data.page.list
  613. this.pageIndex = data.page.currPage
  614. this.pageSize = data.page.pageSize
  615. this.totalPage = data.page.totalCount
  616. }
  617. })
  618. },
  619. // 每页数
  620. sizeChangeHandle (val) {
  621. this.pageSize = val
  622. this.pageIndex = 1
  623. this.getDataList()
  624. },
  625. // 当前页
  626. currentChangeHandle (val) {
  627. this.pageIndex = val
  628. this.getDataList()
  629. },
  630. // 多选
  631. selectionChangeHandle (val) {
  632. this.dataListSelections = val
  633. },
  634. // 获取方法数据列表
  635. getBaseList (val,type) {
  636. this.tagNo = val
  637. this.$nextTick(() => {
  638. let strVal = ''
  639. if (val === 210) {
  640. strVal = this.detailData.samplingQtyNo
  641. this.$refs.baseList.init(val, strVal)
  642. }
  643. if (val === 209) {
  644. strVal = this.detailData.samplingQtyRankNo
  645. this.$refs.baseList.init(val, strVal)
  646. }
  647. if (val === 208) {
  648. strVal = this.detailData.samplingLevelNo
  649. this.$refs.baseList.init(val, strVal)
  650. }
  651. })
  652. },
  653. // 列表方法的回调
  654. getBaseData (val) {
  655. if (this.tagNo === 210) {
  656. this.modalData.samplingQtyNo = val.sampling_qty_no
  657. this.modalData.samplingQtyDesc = val.sampling_qty_desc
  658. }
  659. if (this.tagNo === 209) {
  660. this.modalData.samplingQtyRankNo = val.sampling_qty_rank_no
  661. this.modalData.samplingQtyRankDesc = val.sampling_qty_rank_desc
  662. }
  663. if (this.tagNo === 208) {
  664. this.modalData.samplingLevelNo = val.sampling_level_no
  665. this.modalData.samplingLevelDesc = val.sampling_level_desc
  666. }
  667. },
  668. // 新增
  669. addModal () {
  670. this.modalData = {
  671. flag: '1',
  672. site: '',
  673. bu: this.userBuList[0].buNo,
  674. samplingPlanNo: '',
  675. samplingQtyNo: '',
  676. samplingQty: '',
  677. samplingQtyDesc: '',
  678. samplingQtyRankDesc: '',
  679. samplingQtyRankNo: '',
  680. minQty: '',
  681. maxQty: '',
  682. samplingLevelNo: '',
  683. samplingLevelDesc: '',
  684. samplingPlanActive: 'Y',
  685. createBy: this.$store.state.user.name,
  686. updateBy: this.$store.state.user.name
  687. }
  688. this.modalDisableFlag = false
  689. this.modalFlag = true
  690. },
  691. // 修改
  692. updateModal (row) {
  693. this.modalData = {
  694. flag: '2',
  695. bu: row.site + '_' + row.buNo,
  696. site: row.site,
  697. samplingPlanNo: row.samplingPlanNo,
  698. samplingPlanDesc: row.samplingPlanDesc,
  699. samplingQtyNo: row.samplingQtyNo,
  700. samplingQty: row.samplingQty,
  701. samplingQtyDesc: row.samplingQtyDesc,
  702. samplingQtyRankDesc: row.samplingQtyRankDesc,
  703. samplingQtyRankNo: row.samplingQtyRankNo,
  704. minQty: row.minQty,
  705. maxQty: row.maxQty,
  706. samplingLevelNo: row.samplingLevelNo,
  707. samplingLevelDesc: row.samplingLevelDesc,
  708. samplingPlanActive: row.samplingPlanActive,
  709. createBy: this.$store.state.user.name,
  710. updateBy: this.$store.state.user.name
  711. }
  712. this.modalDisableFlag = true
  713. this.modalFlag = true
  714. },
  715. // 删除
  716. deleteModal (row) {
  717. this.$confirm(`是否删除这个矩阵?`, '提示', {
  718. confirmButtonText: '确定',
  719. cancelButtonText: '取消',
  720. type: 'warning'
  721. }).then(() => {
  722. samplingInspectionPlanDelete(row).then(({data}) => {
  723. if (data && data.code === 0) {
  724. this.getDataList()
  725. this.$message({
  726. message: '操作成功',
  727. type: 'success',
  728. duration: 1500,
  729. onClose: () => {}
  730. })
  731. } else {
  732. this.$alert(data.msg, '错误', {
  733. confirmButtonText: '确定'
  734. })
  735. }
  736. })
  737. }).catch(() => {
  738. })
  739. },
  740. saveData () {
  741. if (this.modalData.bu === '' || this.modalData.bu == null) {
  742. this.$message.warning('请选择BU!')
  743. return
  744. }
  745. if (this.modalData.samplingPlanDesc === '' || this.modalData.samplingPlanDesc == null) {
  746. this.$message.warning('请输入矩阵名称!')
  747. return
  748. }
  749. if (this.modalData.samplingQtyNo === '' || this.modalData.samplingQtyNo == null) {
  750. this.$message.warning('请选择样本量编码!')
  751. return
  752. }
  753. if (this.modalData.samplingQtyRankNo === '' || this.modalData.samplingQtyRankNo == null) {
  754. this.$message.warning('请选择批量级次编码!')
  755. return
  756. }
  757. if (this.modalData.samplingLevelNo === '' || this.modalData.samplingLevelNo == null) {
  758. this.$message.warning('请选择检验水平编码!')
  759. return
  760. }
  761. if (this.modalData.samplingPlanActive === '' || this.modalData.samplingPlanActive == null) {
  762. this.$message.warning('请选择是否在用!')
  763. return
  764. }
  765. if (this.modalData.flag === '1') {
  766. samplingInspectionPlanSave(this.modalData).then(({data}) => {
  767. if (data && data.code === 0) {
  768. this.getDataList()
  769. this.modalFlag = false
  770. this.$message({
  771. message: '操作成功',
  772. type: 'success',
  773. duration: 1500,
  774. onClose: () => {}
  775. })
  776. } else {
  777. this.$alert(data.msg, '错误', {
  778. confirmButtonText: '确定'
  779. })
  780. }
  781. })
  782. } else {
  783. samplingInspectionPlanUpdate(this.modalData).then(({data}) => {
  784. if (data && data.code === 0) {
  785. this.getDataList()
  786. this.modalFlag = false
  787. this.$message({
  788. message: '操作成功',
  789. type: 'success',
  790. duration: 1500,
  791. onClose: () => {}
  792. })
  793. } else {
  794. this.$alert(data.msg, '错误', {
  795. confirmButtonText: '确定'
  796. })
  797. }
  798. })
  799. }
  800. },
  801. // 校验用户是否收藏
  802. favoriteIsOk () {
  803. let userFavorite = {
  804. userId: this.$store.state.user.id,
  805. languageCode: this.$i18n.locale
  806. }
  807. userFavoriteList(userFavorite).then(({data}) => {
  808. for (let i = 0; i < data.list.length; i++) {
  809. if (this.$route.meta.menuId === data.list[i].menuId) {
  810. this.favorite = true
  811. }
  812. }
  813. })
  814. },
  815. // 收藏 OR 取消收藏
  816. favoriteFunction () {
  817. let userFavorite = {
  818. userId: this.$store.state.user.id,
  819. functionId: this.$route.meta.menuId,
  820. }
  821. if (this.favorite) {
  822. removeUserFavorite(userFavorite).then(({data}) => {
  823. this.$message.success(data.msg)
  824. this.favorite = false
  825. })
  826. } else {
  827. // 收藏
  828. saveUserFavorite(userFavorite).then(({data}) => {
  829. this.$message.success(data.msg)
  830. this.favorite = true
  831. })
  832. }
  833. },
  834. //导出excel
  835. async createExportData () {
  836. this.searchData.limit = -1
  837. this.searchData.page = 1
  838. await samplingInspectionPlanSearch(this.searchData).then(({data}) => {
  839. this.exportList = data.page.list
  840. })
  841. return this.exportList
  842. },
  843. startDownload() {},
  844. finishDownload() {},
  845. fields () {
  846. let json = "{"
  847. this.columnList.forEach((item, index) => {
  848. if (index == this.columnList.length - 1) {
  849. json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\""
  850. } else {
  851. json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\"" + ","
  852. }
  853. })
  854. json += "}"
  855. let s = eval("(" + json + ")")
  856. return s
  857. },
  858. // 动态列开始 获取 用户保存的 格式列
  859. async getTableUserColumn (tableId, columnId) {
  860. let queryTableUser = {
  861. userId: this.$store.state.user.name,
  862. functionId: this.$route.meta.menuId,
  863. tableId: tableId,
  864. status: true,
  865. languageCode: this.$i18n.locale
  866. }
  867. await getTableUserListLanguage(queryTableUser).then(({data}) => {
  868. if (data.rows.length > 0) {
  869. //this.columnList1 = []
  870. switch (columnId) {
  871. case 1:
  872. this.columnList = data.rows
  873. break;
  874. // case 2:
  875. // this.columnDetailList = data.rows
  876. // break;
  877. // case 3:
  878. // this.columnList2 = data.rows
  879. // break;
  880. // case 4:
  881. // this.columnList3 = data.rows
  882. // break;
  883. }
  884. } else {
  885. this.getColumnList(tableId, columnId)
  886. }
  887. })
  888. },
  889. // 获取 tableDefault 列
  890. async getColumnList(tableId, columnId) {
  891. let queryTable = {
  892. functionId: this.$route.meta.menuId,
  893. tableId: tableId,
  894. languageCode: this.$i18n.locale
  895. }
  896. await getTableDefaultListLanguage(queryTable).then(({data}) => {
  897. if (!data.rows.length == 0) {
  898. switch (columnId) {
  899. case 1:
  900. this.columnList = data.rows
  901. break;
  902. // case 2:
  903. // this.columnDetailList = data.rows
  904. // break;
  905. // case 3:
  906. // this.columnList2 = data.rows
  907. // break;
  908. // case 4:
  909. // this.columnList3 = data.rows
  910. // break;
  911. }
  912. } else {
  913. // this.showDefault = true.
  914. }
  915. })
  916. },
  917. //获取按钮的权限数据
  918. getButtonAuthData () {
  919. let searchFlag = this.isAuth(this.menuId+":search")
  920. let saveFlag = this.isAuth(this.menuId+":save")
  921. let updateFlag = this.isAuth(this.menuId+":update")
  922. let deleteFlag = this.isAuth(this.menuId+":delete")
  923. //处理页面的权限数据
  924. this.authSearch = !searchFlag
  925. this.authSave = !saveFlag
  926. this.authUpdate = !updateFlag
  927. this.authDelete = !deleteFlag
  928. },
  929. }
  930. }
  931. </script>