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

1141 lines
37 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.samplingProgrammeNo" clearable style="width: 120px"></el-input>
  23. </el-form-item>
  24. <el-form-item :label="'抽样方案名称'">
  25. <el-input v-model="searchData.samplingProgrammeDesc" clearable style="width: 120px"></el-input>
  26. </el-form-item>
  27. <el-form-item :label="'抽样方案代码'">
  28. <el-input v-model="searchData.samplingProgrammeCode" clearable style="width: 120px"></el-input>
  29. </el-form-item>
  30. <el-form-item :label="' '">
  31. <el-button v-if="!authSearch" type="primary" @click="getDataList()">查询</el-button>
  32. <el-button v-if="!authSave" type="primary" @click="addModal()">新增</el-button>
  33. <download-excel
  34. :fields="fields()"
  35. :data="exportData"
  36. type="xls"
  37. :name="exportName"
  38. :header="exportHeader"
  39. :footer="exportFooter"
  40. :fetch="createExportData"
  41. :before-generate="startDownload"
  42. :before-finish="finishDownload"
  43. worksheet="导出信息"
  44. class="el-button el-button--primary el-button--medium">
  45. {{ "导出" }}
  46. </download-excel>
  47. </el-form-item>
  48. </el-form>
  49. <!-- 展示列表 -->
  50. <el-table
  51. :height="height"
  52. :data="dataList"
  53. border
  54. style="width: 100%;">
  55. <el-table-column
  56. v-for="(item,index) in columnList" :key="index"
  57. :sortable="item.columnSortable"
  58. :prop="item.columnProp"
  59. :header-align="item.headerAlign"
  60. :show-overflow-tooltip="item.showOverflowTooltip"
  61. :align="item.align"
  62. :fixed="item.fixed===''?false:item.fixed"
  63. :min-width="item.columnWidth"
  64. :label="item.columnLabel">
  65. <template slot-scope="scope">
  66. <span v-if="!item.columnHidden">{{scope.row[item.columnProp]}}</span>
  67. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
  68. </template>
  69. </el-table-column>
  70. <el-table-column
  71. fixed="right"
  72. header-align="center"
  73. align="center"
  74. width="160"
  75. label="操作">
  76. <template slot-scope="scope">
  77. <a v-if="!authDetail" type="text" size="small" @click="detailModal(scope.row)">矩阵详情</a>
  78. <a v-if="!authDelete" type="text" size="small" @click="deleteData(scope.row)">删除</a>
  79. </template>
  80. </el-table-column>
  81. </el-table>
  82. <!-- 分页栏 -->
  83. <el-pagination
  84. @size-change="sizeChangeHandle"
  85. @current-change="currentChangeHandle"
  86. :current-page="pageIndex"
  87. :page-sizes="[20, 50, 100, 200, 500]"
  88. :page-size="pageSize"
  89. :total="totalPage"
  90. layout="total, sizes, prev, pager, next, jumper">
  91. </el-pagination>
  92. <!-- 抽样方案新增/修改 -->
  93. <el-dialog title="新增抽样方案" :close-on-click-modal="false" v-drag :visible.sync="modalFlag" width="400px">
  94. <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
  95. <el-form-item label="BU" prop="bu" :rules="rules.bu">
  96. <el-select v-model="modalData.bu" placeholder="请选择" :disabled="modalDisableFlag" style="width: 353px">
  97. <el-option
  98. v-for = "i in userBuList"
  99. :key = "i.buNo"
  100. :label = "i.buNo"
  101. :value = "i.buNo">
  102. <span style="float: left;width: 100px">{{ i.sitename }}</span>
  103. <span style="float: right; color: #8492a6;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; font-size: 11px;width: 60px">
  104. {{ i.buDesc }}
  105. </span>
  106. </el-option>
  107. </el-select>
  108. </el-form-item>
  109. </el-form>
  110. <el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
  111. <el-form-item label="抽样方案名称:" prop="samplingProgrammeDesc" :rules="rules.samplingProgrammeDescType">
  112. <el-input v-model="modalData.samplingProgrammeDesc" style="width: 170px"></el-input>
  113. </el-form-item>
  114. <el-form-item label="抽样方案代码:" prop="samplingProgrammeCode" :rules="rules.samplingProgrammeCodeType">
  115. <el-input v-model="modalData.samplingProgrammeCode" style="width: 170px"></el-input>
  116. </el-form-item>
  117. </el-form>
  118. <el-footer style="height:40px;margin-top: 10px;text-align:center">
  119. <el-button type="primary" @click="saveData()">保存</el-button>
  120. <el-button type="primary" @click="modalFlag = false">关闭</el-button>
  121. </el-footer>
  122. </el-dialog>
  123. <!-- 检验模板 -->
  124. <el-dialog title="矩阵详情" :close-on-click-modal="false" v-drag :visible.sync="detailModelFlag" width="1500px">
  125. <el-form :inline="true" label-position="top">
  126. <el-form-item :label="'抽样方案编码'">
  127. <el-input v-model="detailData.samplingProgrammeNo" readonly style="width: 100px"></el-input>
  128. </el-form-item>
  129. <el-form-item :label="'抽样方案名称'">
  130. <el-input v-model="detailData.samplingProgrammeDesc" readonly style="width: 150px"></el-input>
  131. </el-form-item>
  132. <el-form-item :label="'抽样方案代码'">
  133. <el-input v-model="detailData.samplingProgrammeCode" readonly style="width: 150px"></el-input>
  134. </el-form-item>
  135. <el-form-item :label="' '">
  136. <el-button type="primary" @click="addFastModal()">新增</el-button>
  137. </el-form-item>
  138. </el-form>
  139. <!-- 检验项目展示列表 -->
  140. <el-table
  141. :height="300"
  142. :data="detailList"
  143. border
  144. style="width: 100%;">
  145. <el-table-column
  146. v-for="(item,index) in columnDetailList" :key="index"
  147. :sortable="item.columnSortable"
  148. :prop="item.columnProp"
  149. :header-align="item.headerAlign"
  150. :show-overflow-tooltip="item.showOverflowTooltip"
  151. :align="item.align"
  152. :fixed="item.fixed==''?false:item.fixed"
  153. :min-width="item.columnWidth"
  154. :label="item.columnLabel">
  155. <template slot-scope="scope">
  156. <span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span>
  157. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
  158. </template>
  159. </el-table-column>
  160. <el-table-column
  161. fixed="right"
  162. header-align="center"
  163. align="center"
  164. width="80"
  165. label="操作">
  166. <template slot-scope="scope">
  167. <a type="text" size="small" @click="deleteSamplingProgrammeDetails(scope.row)">删除矩阵</a>
  168. </template>
  169. </el-table-column>
  170. </el-table>
  171. <el-footer style="height:40px;margin-top: 20px;text-align:center">
  172. <el-button type="primary" @click="detailModelFlag = false">关闭</el-button>
  173. </el-footer>
  174. </el-dialog>
  175. <!-- 矩阵详情->快速新增 -->
  176. <el-dialog title="新增" @close="refreshDetailList" :close-on-click-modal="false" v-drag :visible.sync="fastAddFlag" width="900px">
  177. <div style="font-size: 12px">
  178. <el-form :inline="true" label-position="top" :model="detailData">
  179. <el-form-item :label="'方案编码'">
  180. <el-input v-model="detailData.samplingProgrammeNo" readonly style="width: 120px"></el-input>
  181. </el-form-item>
  182. <el-form-item :label="'方案名称'">
  183. <el-input v-model="detailData.samplingProgrammeDesc" readonly style="width: 240px"></el-input>
  184. </el-form-item>
  185. </el-form>
  186. </div>
  187. <el-container style="margin-top: 0px;">
  188. <el-main style="width: 400px;padding: 0px">
  189. <span style="font-size: 12px" >可选矩阵</span>
  190. <el-table
  191. height="400px"
  192. :data="itemList1"
  193. border
  194. ref="itemTable1"
  195. @row-click="itemClickRow1"
  196. @selection-change="selectionItem1"
  197. highlight-current-row
  198. style="width: 100%">
  199. <el-table-column
  200. type="selection"
  201. header-align="center"
  202. align="center"
  203. :selectable="selectFlag"
  204. width="50">
  205. </el-table-column>
  206. <el-table-column
  207. prop="samplingPlanNo"
  208. header-align="center"
  209. align="center"
  210. min-width="110"
  211. label="矩阵编码">
  212. </el-table-column>
  213. <el-table-column
  214. prop="samplingPlanDesc"
  215. header-align="center"
  216. align="center"
  217. min-width="170"
  218. label="矩阵名称">
  219. </el-table-column>
  220. </el-table>
  221. </el-main>
  222. <el-main style="width: 100px;padding: 0px">
  223. <div style="margin-top: 182px;margin-left: 18px">
  224. <el-button type="primary" @click="addItem()">添加>></el-button>
  225. </div>
  226. <div style="margin-top: 15px;margin-left: 18px">
  227. <el-button type="primary" @click="deleteItem()">删除<<</el-button>
  228. </div>
  229. </el-main>
  230. <el-main style="width: 400px;padding: 0px">
  231. <span style="font-size: 12px">已有矩阵</span>
  232. <el-table
  233. height="400px"
  234. :data="itemList2"
  235. border
  236. ref="itemTable2"
  237. @row-click="itemClickRow2"
  238. @selection-change="selectionItem2"
  239. highlight-current-row
  240. style="width: 100%">
  241. <el-table-column
  242. type="selection"
  243. header-align="center"
  244. align="center"
  245. :selectable="selectFlag"
  246. width="50">
  247. </el-table-column>
  248. <el-table-column
  249. prop="samplingPlanNo"
  250. header-align="center"
  251. align="center"
  252. min-width="110"
  253. label="矩阵编码">
  254. </el-table-column>
  255. <el-table-column
  256. prop="samplingPlanDesc"
  257. header-align="center"
  258. align="center"
  259. min-width="170"
  260. label="矩阵名称">
  261. </el-table-column>
  262. </el-table>
  263. </el-main>
  264. </el-container>
  265. <el-footer style="height:40px;margin-top: 20px;text-align:center">
  266. <el-button type="primary" @click="fastAddFlag = false">关闭</el-button>
  267. </el-footer>
  268. </el-dialog>
  269. <Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist>
  270. </div>
  271. </template>
  272. <script>
  273. import {
  274. samplingProgrammeSearch, // 查询抽样方案
  275. samplingProgrammeSave, // 新增抽样方案
  276. samplingProgrammeDelete, // 删除抽样方案
  277. searchSamplingProgrammeDetails, // 搜索抽样方案中的矩阵
  278. getPlanLists, // 获取矩阵列表
  279. saveSamplingProgrammeDetails, // 新增抽样方案中的矩阵
  280. deleteSamplingProgrammeDetails, // 删除抽样方案中的矩阵
  281. getSiteAndBuByUserName
  282. } from "@/api/qc/qc.js"
  283. import {getTableDefaultListLanguage, getTableUserListLanguage} from "@/api/table.js"
  284. import Chooselist from '@/views/modules/common/Chooselist_eam'
  285. import {userFavoriteList, saveUserFavorite, removeUserFavorite} from '@/api/userFavorite.js'
  286. export default {
  287. components: {
  288. Chooselist
  289. },
  290. data () {
  291. return {
  292. // 是否收藏
  293. favorite: false,
  294. // 导出 start
  295. exportData: [],
  296. exportName: "根据物料设置检验模板" + this.dayjs().format('YYYYMMDDHHmmss'),
  297. exportHeader: ["根据物料设置检验模板"],
  298. exportFooter: [],
  299. exportList: [],
  300. // 导出 end
  301. tagNo: '',
  302. searchData: {
  303. site: '',
  304. userName: this.$store.state.user.name,
  305. samplingProgrammeNo: '',
  306. samplingProgrammeDesc: '',
  307. samplingProgrammeCode: '',
  308. buDesc: '',
  309. page: 1,
  310. limit: 10,
  311. },
  312. height: 200,
  313. pageIndex: 1,
  314. pageSize: 20,
  315. totalPage: 0,
  316. modalFlag: false,
  317. modalDisableFlag: false,
  318. modalData: {
  319. flag: '',
  320. site: '',
  321. bu: '',
  322. samplingProgrammeNo: '',
  323. samplingProgrammeDesc: '',
  324. samplingProgrammeCode: '',
  325. createBy: this.$store.state.user.name,
  326. updateBy: this.$store.state.user.name,
  327. },
  328. detailData: {
  329. site: '',
  330. buNo: '',
  331. samplingProgrammeNo: '',
  332. samplingProgrammeDesc: '',
  333. samplingProgrammeCode: '',
  334. createBy: this.$store.state.user.name
  335. },
  336. columnList: [
  337. {
  338. userId: this.$store.state.user.name,
  339. functionId: 301013,
  340. serialNumber: '301013Table1BuDesc',
  341. tableId: "301013Table1",
  342. tableName: "抽样方案表",
  343. columnWidth: 100,
  344. columnProp: 'buDesc',
  345. headerAlign: "center",
  346. align: "center",
  347. columnLabel: 'BU',
  348. columnHidden: false,
  349. columnImage: false,
  350. columnSortable: false,
  351. sortLv: 0,
  352. status: true,
  353. fixed: '',
  354. },
  355. {
  356. userId: this.$store.state.user.name,
  357. functionId: 301013,
  358. serialNumber: '301013Table1SamplingProgrammeNo',
  359. tableId: "301013Table1",
  360. tableName: "抽样方案表",
  361. columnWidth: 211,
  362. columnProp: 'samplingProgrammeNo',
  363. headerAlign: "center",
  364. align: "center",
  365. columnLabel: '抽样方案编码',
  366. columnHidden: false,
  367. columnImage: false,
  368. columnSortable: false,
  369. sortLv: 0,
  370. status: true,
  371. fixed: '',
  372. },
  373. {
  374. userId: this.$store.state.user.name,
  375. functionId: 301013,
  376. serialNumber: '301013Table1SamplingProgrammeDesc',
  377. tableId: "301013Table1",
  378. tableName: "抽样方案表",
  379. columnWidth: 208,
  380. columnProp: 'samplingProgrammeDesc',
  381. headerAlign: "center",
  382. align: "center",
  383. columnLabel: '抽样方案名称',
  384. columnHidden: false,
  385. columnImage: false,
  386. columnSortable: false,
  387. sortLv: 0,
  388. status: true,
  389. fixed: '',
  390. },
  391. {
  392. userId: this.$store.state.user.name,
  393. functionId: 301013,
  394. serialNumber: '301013Table1SamplingProgrammeCode',
  395. tableId: "301013Table1",
  396. tableName: "抽样方案表",
  397. columnWidth: 208,
  398. columnProp: 'samplingProgrammeCode',
  399. headerAlign: "center",
  400. align: "center",
  401. columnLabel: '抽样方案代码',
  402. columnHidden: false,
  403. columnImage: false,
  404. columnSortable: false,
  405. sortLv: 0,
  406. status: true,
  407. fixed: '',
  408. },
  409. {
  410. userId: this.$store.state.user.name,
  411. functionId: 301013,
  412. serialNumber: '301013Table1CreateTime',
  413. tableId: "301013Table1",
  414. tableName: "抽样方案表",
  415. columnWidth: 208,
  416. columnProp: 'createTime',
  417. headerAlign: "center",
  418. align: "center",
  419. columnLabel: '创建时间',
  420. columnHidden: false,
  421. columnImage: false,
  422. columnSortable: false,
  423. sortLv: 0,
  424. status: true,
  425. fixed: '',
  426. },
  427. {
  428. userId: this.$store.state.user.name,
  429. functionId: 301013,
  430. serialNumber: '301013Table1CreateBy',
  431. tableId: "301013Table1",
  432. tableName: "抽样方案表",
  433. columnWidth: 208,
  434. columnProp: 'createBy',
  435. headerAlign: "center",
  436. align: "center",
  437. columnLabel: '创建人',
  438. columnHidden: false,
  439. columnImage: false,
  440. columnSortable: false,
  441. sortLv: 0,
  442. status: true,
  443. fixed: '',
  444. },
  445. {
  446. userId: this.$store.state.user.name,
  447. functionId: 301013,
  448. serialNumber: '301013Table1UpdateDate',
  449. tableId: "301013Table1",
  450. tableName: "抽样方案表",
  451. columnWidth: 208,
  452. columnProp: 'updateDate',
  453. headerAlign: "center",
  454. align: "center",
  455. columnLabel: '更新时间',
  456. columnHidden: false,
  457. columnImage: false,
  458. columnSortable: false,
  459. sortLv: 0,
  460. status: true,
  461. fixed: '',
  462. },
  463. {
  464. userId: this.$store.state.user.name,
  465. functionId: 301013,
  466. serialNumber: '301013Table1UpdateBy',
  467. tableId: "301013Table1",
  468. tableName: "抽样方案表",
  469. columnWidth: 208,
  470. columnProp: 'updateBy',
  471. headerAlign: "center",
  472. align: "center",
  473. columnLabel: '更新人',
  474. columnHidden: false,
  475. columnImage: false,
  476. columnSortable: false,
  477. sortLv: 0,
  478. status: true,
  479. fixed: '',
  480. },
  481. ],
  482. detailModelFlag: false,
  483. detailList: [],
  484. itemData:{
  485. itemNo:'',
  486. valueNo:'',
  487. availableValue:'',
  488. itemType:'D',
  489. createdBy: this.$store.state.user.name
  490. },
  491. dataList: [],
  492. // 展示列集
  493. columnDetailList: [
  494. {
  495. userId: this.$store.state.user.name,
  496. functionId: 301013,
  497. serialNumber: '301013Table2SamplingPlanNo',
  498. tableId: "301013Table2",
  499. tableName: "矩阵详情表",
  500. columnWidth: 181,
  501. columnProp: 'samplingPlanNo',
  502. headerAlign: "center",
  503. align: "center",
  504. columnLabel: '矩阵编码',
  505. columnHidden: false,
  506. columnImage: false,
  507. columnSortable: false,
  508. sortLv: 0,
  509. status: true,
  510. fixed: '',
  511. },
  512. {
  513. userId: this.$store.state.user.name,
  514. functionId: 301013,
  515. serialNumber: '301013Table2SamplingPlanDesc',
  516. tableId: "301013Table2",
  517. tableName: "矩阵详情表",
  518. columnWidth: 174,
  519. columnProp: 'samplingPlanDesc',
  520. headerAlign: "center",
  521. align: "center",
  522. columnLabel: '矩阵名称',
  523. columnHidden: false,
  524. columnImage: false,
  525. columnSortable: false,
  526. sortLv: 0,
  527. status: true,
  528. fixed: '',
  529. },
  530. {
  531. userId: this.$store.state.user.name,
  532. functionId: 301013,
  533. serialNumber: '301013Table2SamplingQtyDesc',
  534. tableId: "301013Table2",
  535. tableName: "矩阵详情表",
  536. columnWidth: 174,
  537. columnProp: 'samplingQtyDesc',
  538. headerAlign: "center",
  539. align: "center",
  540. columnLabel: '样本量字码',
  541. columnHidden: false,
  542. columnImage: false,
  543. columnSortable: false,
  544. sortLv: 0,
  545. status: true,
  546. fixed: '',
  547. },
  548. {
  549. userId: this.$store.state.user.name,
  550. functionId: 301013,
  551. serialNumber: '301013Table2SamplingQty',
  552. tableId: "301013Table2",
  553. tableName: "矩阵详情表",
  554. columnWidth: 174,
  555. columnProp: 'samplingQty',
  556. headerAlign: "center",
  557. align: "center",
  558. columnLabel: '样本量',
  559. columnHidden: false,
  560. columnImage: false,
  561. columnSortable: false,
  562. sortLv: 0,
  563. status: true,
  564. fixed: '',
  565. },
  566. {
  567. userId: this.$store.state.user.name,
  568. functionId: 301013,
  569. serialNumber: '301013Table2SamplingQtyRankDesc',
  570. tableId: "301013Table2",
  571. tableName: "矩阵详情表",
  572. columnWidth: 174,
  573. columnProp: 'samplingQtyRankDesc',
  574. headerAlign: "center",
  575. align: "center",
  576. columnLabel: '批量级次',
  577. columnHidden: false,
  578. columnImage: false,
  579. columnSortable: false,
  580. sortLv: 0,
  581. status: true,
  582. fixed: '',
  583. },
  584. {
  585. userId: this.$store.state.user.name,
  586. functionId: 301013,
  587. serialNumber: '301013Table2MinQty',
  588. tableId: "301013Table2",
  589. tableName: "矩阵详情表",
  590. columnWidth: 174,
  591. columnProp: 'minQty',
  592. headerAlign: "center",
  593. align: "center",
  594. columnLabel: '最小抽样数',
  595. columnHidden: false,
  596. columnImage: false,
  597. columnSortable: false,
  598. sortLv: 0,
  599. status: true,
  600. fixed: '',
  601. },
  602. {
  603. userId: this.$store.state.user.name,
  604. functionId: 301013,
  605. serialNumber: '301013Table2MaxQty',
  606. tableId: "301013Table2",
  607. tableName: "矩阵详情表",
  608. columnWidth: 174,
  609. columnProp: 'maxQty',
  610. headerAlign: "center",
  611. align: "center",
  612. columnLabel: '最大抽样数',
  613. columnHidden: false,
  614. columnImage: false,
  615. columnSortable: false,
  616. sortLv: 0,
  617. status: true,
  618. fixed: '',
  619. },
  620. {
  621. userId: this.$store.state.user.name,
  622. functionId: 301013,
  623. serialNumber: '301013Table2SamplingLevelDesc',
  624. tableId: "301013Table2",
  625. tableName: "矩阵详情表",
  626. columnWidth: 174,
  627. columnProp: 'samplingLevelDesc',
  628. headerAlign: "center",
  629. align: "center",
  630. columnLabel: '抽样等级',
  631. columnHidden: false,
  632. columnImage: false,
  633. columnSortable: false,
  634. sortLv: 0,
  635. status: true,
  636. fixed: '',
  637. },
  638. ],
  639. // 快速添加
  640. fastAddFlag: false,
  641. itemList1: [],
  642. itemList2: [],
  643. itemListRow1: {},
  644. itemListRow2: {},
  645. tempLevelRow: '',
  646. tempPlanRow: '',
  647. options: [],
  648. itemSelections1: [],
  649. itemSelections2: [],
  650. rules: {
  651. samplingProgrammeDescType:[
  652. {
  653. required: true,
  654. message: ' ',
  655. trigger: ['blur','change']
  656. }
  657. ],
  658. samplingProgrammeCodeType:[
  659. {
  660. required: true,
  661. message: ' ',
  662. trigger: ['blur','change']
  663. }
  664. ],
  665. bu:[
  666. {
  667. required: true,
  668. message: ' ',
  669. trigger: ['blur','change']
  670. }
  671. ]
  672. },
  673. userBuList: [],
  674. authSearch: false,
  675. authSave: false,
  676. authDetail: false,
  677. authDelete: false,
  678. menuId: this.$route.meta.menuId,
  679. }
  680. },
  681. mounted () {
  682. this.$nextTick(() => {
  683. this.height = window.innerHeight - 210
  684. })
  685. },
  686. created () {
  687. // 按钮控制
  688. this.getButtonAuthData()
  689. // 获取用户的 site 和 bu
  690. this.getSiteAndBuByUserName()
  691. // 校验用户是否收藏
  692. this.favoriteIsOk()
  693. // 动态列
  694. this.getTableUserColumn(this.$route.meta.menuId+'table1',1)
  695. this.getTableUserColumn(this.$route.meta.menuId+'table2',2)
  696. if (!this.authSearch) {
  697. // 获取数据列表
  698. this.getDataList()
  699. }
  700. },
  701. methods: {
  702. // 获取用户的bu
  703. getSiteAndBuByUserName () {
  704. let tempData = {
  705. username: this.$store.state.user.name,
  706. }
  707. getSiteAndBuByUserName(tempData).then(({data}) => {
  708. if (data.code === 0) {
  709. this.userBuList = data.rows
  710. }
  711. })
  712. },
  713. chooseLevel (row) {
  714. this.tempLevelRow = row
  715. this.getBaseList(208)
  716. },
  717. choosePlanRow (row) {
  718. this.tempPlanRow = row
  719. this.getBaseList(1049)
  720. },
  721. // 获取基础数据列表S
  722. getBaseList (val,type) {
  723. this.tagNo = val
  724. this.$nextTick(() => {
  725. let strVal = ''
  726. if (val === 208) {
  727. strVal = this.tempLevelRow.samplingLevelNo
  728. this.$refs.baseList.init(val, strVal)
  729. }
  730. if (val === 1049) {
  731. strVal = this.tempPlanRow.samplingPlanNo
  732. this.$refs.baseList.init(val, strVal)
  733. }
  734. })
  735. },
  736. // 列表方法的回调
  737. getBaseData (val) {
  738. if (this.tagNo === 208) {
  739. this.tempLevelRow.samplingLevelNo = val.sampling_level_no
  740. this.tempLevelRow.samplingLevelDesc = val.sampling_level_desc
  741. }
  742. if (this.tagNo === 1049) {
  743. this.tempPlanRow.samplingPlanNo = val.sampling_plan_no
  744. }
  745. },
  746. // 获取数据列表
  747. getDataList () {
  748. this.searchData.limit = this.pageSize
  749. this.searchData.page = this.pageIndex
  750. samplingProgrammeSearch(this.searchData).then(({data}) => {
  751. if (data.code === 0) {
  752. this.dataList = data.page.list
  753. this.pageIndex = data.page.currPage
  754. this.pageSize = data.page.pageSize
  755. this.totalPage = data.page.totalCount
  756. }
  757. })
  758. },
  759. // 每页数
  760. sizeChangeHandle (val) {
  761. this.pageSize = val
  762. this.pageIndex = 1
  763. this.getDataList()
  764. },
  765. // 当前页
  766. currentChangeHandle (val) {
  767. this.pageIndex = val
  768. this.getDataList()
  769. },
  770. addModal () {
  771. this.modalData = {
  772. flag: '1',
  773. site: '',
  774. bu: this.userBuList[0].buNo,
  775. samplingProgrammeNo: '',
  776. samplingProgrammeDesc: '',
  777. samplingProgrammeCode: '',
  778. createBy: this.$store.state.user.name,
  779. updateBy: this.$store.state.user.name,
  780. }
  781. this.modalDisableFlag = false
  782. this.modalFlag = true
  783. },
  784. // 删除
  785. deleteData (row) {
  786. this.$confirm(`是否删除这个抽样方案?`, '提示', {
  787. confirmButtonText: '确定',
  788. cancelButtonText: '取消',
  789. type: 'warning'
  790. }).then(() => {
  791. samplingProgrammeDelete(row).then(({data}) => {
  792. if (data && data.code === 0) {
  793. this.getDataList()
  794. this.$message({
  795. message: '操作成功',
  796. type: 'success',
  797. duration: 1500,
  798. onClose: () => {}
  799. })
  800. } else {
  801. this.$alert(data.msg, '错误', {
  802. confirmButtonText: '确定'
  803. })
  804. }
  805. })
  806. }).catch(() => {
  807. })
  808. },
  809. // 新增抽样方案
  810. saveData () {
  811. if (this.modalData.bu === '' || this.modalData.bu == null) {
  812. this.$message.warning('请选择BU!')
  813. return
  814. }
  815. if (this.modalData.samplingProgrammeDesc === '' || this.modalData.samplingProgrammeDesc == null) {
  816. this.$message.warning('请输入抽样方案名称!')
  817. return
  818. }
  819. if (this.modalData.samplingProgrammeCode === '' || this.modalData.samplingProgrammeCode == null) {
  820. this.$message.warning('请输入抽样方案代码!')
  821. return
  822. }
  823. if (this.modalData.flag === '1') {
  824. samplingProgrammeSave(this.modalData).then(({data}) => {
  825. if (data && data.code === 0) {
  826. this.getDataList()
  827. this.modalFlag = false
  828. this.$message({
  829. message: '操作成功',
  830. type: 'success',
  831. duration: 1500,
  832. onClose: () => {}
  833. })
  834. } else {
  835. this.$alert(data.msg, '错误', {
  836. confirmButtonText: '确定'
  837. })
  838. }
  839. })
  840. }
  841. },
  842. // 打开矩阵详情
  843. detailModal (row) {
  844. this.detailData.site = row.site
  845. this.detailData.buNo = row.buNo
  846. this.detailData.samplingProgrammeNo = row.samplingProgrammeNo
  847. this.detailData.samplingProgrammeDesc = row.samplingProgrammeDesc
  848. this.detailData.samplingProgrammeCode = row.samplingProgrammeCode
  849. searchSamplingProgrammeDetails(this.detailData).then(({data}) => {
  850. this.detailList = data.rows
  851. })
  852. this.detailModelFlag = true
  853. },
  854. // 新增
  855. addFastModal () {
  856. this.itemSelections1 = null
  857. this.itemSelections2 = null
  858. getPlanLists(this.detailData).then(({data}) => {
  859. this.itemList1 = data.row1
  860. this.itemList2 = data.row2
  861. })
  862. this.fastAddFlag = true
  863. },
  864. // 可选项目
  865. itemClickRow1 (row) {
  866. this.$refs.itemTable1.toggleRowSelection(row)
  867. },
  868. // 已有项目
  869. itemClickRow2 (row) {
  870. this.$refs.itemTable2.toggleRowSelection(row)
  871. },
  872. selectFlag () {
  873. return true
  874. },
  875. selectionItem1 (val) {
  876. this.itemSelections1 = val
  877. },
  878. selectionItem2 (val) {
  879. this.itemSelections2 = val
  880. },
  881. // 添加矩阵
  882. addItem () {
  883. if (this.itemSelections1 == null || this.itemSelections1.length === 0) {
  884. this.$message.warning('请选择可选矩阵!')
  885. return
  886. }
  887. let inData = {
  888. samplingProgrammeNo: this.detailData.samplingProgrammeNo,
  889. planList: this.itemSelections1,
  890. site: this.detailData.site,
  891. buNo: this.detailData.buNo,
  892. updateBy: this.$store.state.user.name,
  893. }
  894. saveSamplingProgrammeDetails(inData).then(({data}) => {
  895. if (data && data.code === 0) {
  896. getPlanLists(this.detailData).then(({data}) => {
  897. this.itemList1 = data.row1
  898. this.itemList2 = data.row2
  899. })
  900. this.itemSelections1 = []
  901. } else {
  902. this.$alert(data.msg, '错误', {
  903. confirmButtonText: '确定'
  904. })
  905. }
  906. })
  907. },
  908. // 删除矩阵
  909. deleteItem () {
  910. if (this.itemSelections2 == null || this.itemSelections2.length === 0) {
  911. this.$message.warning('请选择已有矩阵!')
  912. return
  913. }
  914. let inData = {
  915. samplingProgrammeNo: this.detailData.samplingProgrammeNo,
  916. planList: this.itemSelections2,
  917. site: this.detailData.site,
  918. buNo: this.detailData.buNo,
  919. updateBy: this.$store.state.user.name,
  920. }
  921. deleteSamplingProgrammeDetails(inData).then(({data}) => {
  922. if (data && data.code === 0) {
  923. getPlanLists(this.detailData).then(({data}) => {
  924. this.itemList1 = data.row1
  925. this.itemList2 = data.row2
  926. })
  927. this.itemSelections2 = []
  928. } else {
  929. this.$alert(data.msg, '错误', {
  930. confirmButtonText: '确定'
  931. })
  932. }
  933. })
  934. },
  935. // 关闭后刷新列表
  936. refreshDetailList () {
  937. searchSamplingProgrammeDetails(this.detailData).then(({data}) => {
  938. this.detailList = data.rows
  939. })
  940. },
  941. // 删除抽样方案中的矩阵
  942. deleteSamplingProgrammeDetails (row) {
  943. row.updateBy = this.$store.state.user.name
  944. this.$confirm(`是否删除这个矩阵?`, '提示', {
  945. confirmButtonText: '确定',
  946. cancelButtonText: '取消',
  947. type: 'warning'
  948. }).then(() => {
  949. deleteSamplingProgrammeDetails(row).then(({data}) => {
  950. if (data && data.code === 0) {
  951. searchSamplingProgrammeDetails(this.detailData).then(({data}) => {
  952. this.detailList = data.rows
  953. })
  954. this.$message({
  955. message: '操作成功',
  956. type: 'success',
  957. duration: 1500,
  958. onClose: () => {}
  959. })
  960. } else {
  961. this.$alert(data.msg, '错误', {
  962. confirmButtonText: '确定'
  963. })
  964. }
  965. })
  966. }).catch(() => {
  967. })
  968. },
  969. // 校验用户是否收藏
  970. favoriteIsOk () {
  971. let userFavorite = {
  972. userId: this.$store.state.user.id,
  973. languageCode: this.$i18n.locale
  974. }
  975. userFavoriteList(userFavorite).then(({data}) => {
  976. for (let i = 0; i < data.list.length; i++) {
  977. if (this.$route.meta.menuId === data.list[i].menuId) {
  978. this.favorite = true
  979. }
  980. }
  981. })
  982. },
  983. // 收藏 OR 取消收藏
  984. favoriteFunction () {
  985. let userFavorite = {
  986. userId: this.$store.state.user.id,
  987. functionId: this.$route.meta.menuId,
  988. }
  989. if (this.favorite) {
  990. removeUserFavorite(userFavorite).then(({data}) => {
  991. this.$message.success(data.msg)
  992. this.favorite = false
  993. })
  994. } else {
  995. // 收藏
  996. saveUserFavorite(userFavorite).then(({data}) => {
  997. this.$message.success(data.msg)
  998. this.favorite = true
  999. })
  1000. }
  1001. },
  1002. //导出excel
  1003. async createExportData () {
  1004. this.searchData.limit = -1
  1005. this.searchData.page = 1
  1006. await samplingProgrammeSearch(this.searchData).then(({data}) => {
  1007. this.exportList= data.page.list
  1008. })
  1009. return this.exportList
  1010. },
  1011. startDownload() {},
  1012. finishDownload() {},
  1013. fields () {
  1014. let json = "{"
  1015. this.columnList.forEach((item, index) => {
  1016. if (index == this.columnList.length - 1) {
  1017. json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\""
  1018. } else {
  1019. json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\"" + ","
  1020. }
  1021. })
  1022. json += "}"
  1023. let s = eval("(" + json + ")")
  1024. return s
  1025. },
  1026. // 动态列开始 获取 用户保存的 格式列
  1027. async getTableUserColumn (tableId, columnId) {
  1028. let queryTableUser = {
  1029. userId: this.$store.state.user.name,
  1030. functionId: this.$route.meta.menuId,
  1031. tableId: tableId,
  1032. status: true,
  1033. languageCode: this.$i18n.locale
  1034. }
  1035. await getTableUserListLanguage(queryTableUser).then(({data}) => {
  1036. if (data.rows.length > 0) {
  1037. //this.columnList1 = []
  1038. switch (columnId) {
  1039. case 1:
  1040. this.columnList = data.rows
  1041. break;
  1042. case 2:
  1043. this.columnDetailList = data.rows
  1044. break;
  1045. // case 3:
  1046. // this.columnList2 = data.rows
  1047. // break;
  1048. // case 4:
  1049. // this.columnList3 = data.rows
  1050. // break;
  1051. }
  1052. } else {
  1053. this.getColumnList(tableId, columnId)
  1054. }
  1055. })
  1056. },
  1057. // 获取 tableDefault 列
  1058. async getColumnList (tableId, columnId) {
  1059. let queryTable = {
  1060. functionId: this.$route.meta.menuId,
  1061. tableId: tableId,
  1062. languageCode: this.$i18n.locale
  1063. }
  1064. await getTableDefaultListLanguage(queryTable).then(({data}) => {
  1065. if (!data.rows.length == 0) {
  1066. switch (columnId) {
  1067. case 1:
  1068. this.columnList = data.rows
  1069. break;
  1070. case 2:
  1071. this.columnDetailList = data.rows
  1072. break;
  1073. // case 3:
  1074. // this.columnList2 = data.rows
  1075. // break;
  1076. // case 4:
  1077. // this.columnList3 = data.rows
  1078. // break;
  1079. }
  1080. } else {
  1081. // this.showDefault = true.
  1082. }
  1083. })
  1084. },
  1085. //获取按钮的权限数据
  1086. getButtonAuthData () {
  1087. let searchFlag = this.isAuth(this.menuId+":search")
  1088. let saveFlag = this.isAuth(this.menuId+":save")
  1089. let detailFlag = this.isAuth(this.menuId+":detail")
  1090. let deleteFlag = this.isAuth(this.menuId+":delete")
  1091. //处理页面的权限数据
  1092. this.authSearch = !searchFlag
  1093. this.authSave = !saveFlag
  1094. this.authDetail = !detailFlag
  1095. this.authDelete = !deleteFlag
  1096. },
  1097. }
  1098. }
  1099. </script>