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.

1115 lines
34 KiB

4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
  1. <template>
  2. <div class="customer-css" >
  3. <!-- 查询时间和产品 -->
  4. <el-form :inline="true" label-position="top" label-width="100px" style="margin-top: 0px;" >
  5. <el-row>
  6. <el-col :span="24" style="">
  7. <el-form-item :label="'产品编码:'">
  8. <!-- <span style="cursor: pointer" slot="label" @click="getBaseList(1100)"><a href="#">产品编码</a></span> -->
  9. <el-input v-model="searchData.partNo" style="width: 130px"></el-input>
  10. </el-form-item>
  11. <el-form-item :label="'NPC货号:'">
  12. <el-input v-model="searchData.npc" style="width: 130px"></el-input>
  13. </el-form-item>
  14. <el-form-item :label="'产品名称:'">
  15. <el-input v-model="searchData.partDesc" style="width: 130px"></el-input>
  16. </el-form-item>
  17. <el-form-item :label="' '">
  18. <el-button class="customer-bun-min" type="primary" @click="getMainData" style="">查询</el-button>
  19. <el-button @click="addPart()" type="primary" style="margin-left: 2px">新增</el-button>
  20. </el-form-item>
  21. </el-col>
  22. </el-row>
  23. </el-form>
  24. <el-table
  25. :height="height"
  26. :data="mainDataList"
  27. border
  28. ref="mainTable"
  29. highlight-current-row
  30. @row-click="changeData"
  31. v-loading="dataListLoading"
  32. style="margin-top: 0px; width: 100%;">
  33. <el-table-column
  34. v-for="(item,index) in columnArray1" :key="index"
  35. :sortable="item.columnSortable"
  36. :prop="item.columnProp"
  37. :header-align="item.headerAlign"
  38. :show-overflow-tooltip="item.showOverflowTooltip"
  39. :align="item.align"
  40. :fixed="item.fixed==''?false:item.fixed"
  41. :min-width="item.columnWidth"
  42. :label="item.columnLabel">
  43. <template slot-scope="scope">
  44. <span v-if="!item.columnHidden">{{
  45. item.columnProp === 'partStage'
  46. ? formatPartStageDesc(scope.row.partStage)
  47. : scope.row[item.columnProp]
  48. }}</span>
  49. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
  50. style="width: 100px; height: 100px"/></span>
  51. </template>
  52. </el-table-column>
  53. <!-- 操作列 -->
  54. <el-table-column
  55. fixed="right"
  56. header-align="center"
  57. align="center"
  58. width="160"
  59. label="Action">
  60. <template slot-scope="scope">
  61. <!-- <el-link style="cursor: pointer" v-if="scope.row.flowStatus === 'COMPLETED' || scope.row.flowStatus === 'TERMINATED'" @click="handleRestart(scope.row)">重新审批 |</el-link>
  62. <el-link style="cursor: pointer" v-if="scope.row.flowStatus === 'RUNNING'" @click="openApproveDialog(scope.row)">审批 |</el-link> -->
  63. <el-link style="cursor: pointer" @click="editPart(scope.row)">编辑 |</el-link>
  64. <el-link style="cursor: pointer" @click="deletePart(scope.row)">删除</el-link>
  65. </template>
  66. </el-table-column>
  67. </el-table>
  68. <!-- 分页插件 -->
  69. <el-pagination style="margin-top: 0px"
  70. @size-change="sizeChangeHandle"
  71. @current-change="currentChangeHandle"
  72. :current-page="pageIndex"
  73. :page-sizes="[20, 50, 100, 200, 500]"
  74. :page-size="pageSize"
  75. :total="totalPage"
  76. layout="total, sizes, prev, pager, next, jumper">
  77. </el-pagination>
  78. <el-tabs v-model="activeName" style="margin-top: 0px; width: 99%;" @tab-click="tabClick" class="customer-tab" type="border-card">
  79. <el-tab-pane label="基础信息" name="basicInfo" style="">
  80. <basicInfo ref="basicInfo"></basicInfo>
  81. </el-tab-pane>
  82. <el-tab-pane label="规格参数" name="specParams" style="">
  83. <specParams ref="specParams"></specParams>
  84. </el-tab-pane>
  85. <el-tab-pane label="关联供应商" name="suppliers" style="">
  86. <suppliers ref="suppliers"></suppliers>
  87. </el-tab-pane>
  88. <el-tab-pane label="审批与放行" name="approval" style="">
  89. <approval ref="approval"></approval>
  90. </el-tab-pane>
  91. <el-tab-pane label="附件" name="attachments" style="">
  92. <attachments ref="attachments"></attachments>
  93. </el-tab-pane>
  94. </el-tabs>
  95. <Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist>
  96. <!-- 产品编辑对话框 -->
  97. <el-dialog :title="isAdd ? '新增产品' : '编辑产品'" :visible.sync="partDialogVisible" width="600px" top="3vh" :close-on-click-modal="false" class="part-dialog">
  98. <div class="dialog-content">
  99. <el-form
  100. :model="currentpart"
  101. :rules="partRules"
  102. ref="partForm"
  103. label-position="top"
  104. class="part-form">
  105. <div class="form-section">
  106. <el-row :gutter="24">
  107. <el-col :span="6">
  108. <el-form-item label="产品编码" prop="partNo">
  109. <el-input v-model="currentpart.partNo" :disabled="!isAdd"></el-input>
  110. </el-form-item>
  111. </el-col>
  112. <el-col :span="6">
  113. <el-form-item label="NPC货号" prop="npc">
  114. <el-input v-model="currentpart.npc"></el-input>
  115. </el-form-item>
  116. </el-col>
  117. <el-col :span="6">
  118. <el-form-item>
  119. <span style="cursor: pointer" slot="label" @click="getBaseList(526)"><a href="#">产品分类</a></span>
  120. <el-input v-model="currentpart.category" style="width: 130px"></el-input>
  121. </el-form-item>
  122. </el-col>
  123. <el-col :span="6">
  124. <el-form-item>
  125. <span style="cursor: pointer" slot="label" @click="getBaseList(510)"><a href="#">计量单位</a></span>
  126. <el-input v-model="currentpart.unit" style="width: 130px"></el-input>
  127. </el-form-item>
  128. </el-col>
  129. </el-row>
  130. <el-row :gutter="24">
  131. <el-col :span="12">
  132. <el-form-item label="产品名称" prop="partDesc">
  133. <el-input v-model="currentpart.partDesc"></el-input>
  134. </el-form-item>
  135. </el-col>
  136. <el-col :span="12">
  137. <el-form-item label="产品规格" prop="partSpec">
  138. <el-input v-model="currentpart.partSpec"></el-input>
  139. </el-form-item>
  140. </el-col>
  141. </el-row>
  142. </div>
  143. <div class="form-section">
  144. <el-row :gutter="24">
  145. <el-col :span="6">
  146. <el-form-item >
  147. <span style="cursor: pointer" slot="label" @click="getBaseList(529)"><a href="#">采购员</a></span>
  148. <el-input v-model="currentpart.buyerName" style="width: 130px"></el-input>
  149. </el-form-item>
  150. </el-col>
  151. <el-col :span="6">
  152. <el-form-item >
  153. <span style="cursor: pointer" slot="label" @click="getBaseList(528)"><a href="#">sourcing专员</a></span>
  154. <el-input v-model="currentpart.sourcingName" style="width: 130px"></el-input>
  155. </el-form-item>
  156. </el-col>
  157. <el-col :span="6">
  158. <el-form-item>
  159. <span style="cursor: pointer" slot="label" @click="getBaseList(527)"><a href="#">属性模板</a></span>
  160. <el-input v-model="currentpart.codeNo" ></el-input>
  161. </el-form-item>
  162. </el-col>
  163. <el-col :span="6">
  164. <el-form-item label="状态">
  165. <el-select v-model="currentpart.status" placeholder="请选择" >
  166. <el-option label="启用" value="N"></el-option>
  167. <el-option label="停用" value="Y"></el-option>
  168. </el-select>
  169. </el-form-item>
  170. </el-col>
  171. </el-row>
  172. </div>
  173. <div class="form-section">
  174. <el-row :gutter="24">
  175. <el-col :span="24">
  176. <el-form-item label="备注">
  177. <el-input v-model="currentpart.remark" type="textarea" :rows="2" resize="none" ></el-input>
  178. </el-form-item>
  179. </el-col>
  180. </el-row>
  181. </div>
  182. </el-form>
  183. </div>
  184. <div slot="footer" class="dialog-footer" style="margin-top: 20px">
  185. <el-button type="primary" @click="savePart()">保存</el-button>
  186. <el-button @click="partDialogVisible = false">取消</el-button>
  187. </div>
  188. </el-dialog>
  189. <!-- 审批对话框 - rqrq -->
  190. <!-- <el-dialog
  191. title="审批"
  192. :visible.sync="approveDialogVisible"
  193. width="550px"
  194. :close-on-click-modal="false"
  195. v-drag>
  196. <el-form :model="approveData" label-position="top">
  197. <el-row :gutter="20">
  198. <el-col :span="12">
  199. <el-form-item label="是否特殊放行">
  200. <el-select v-model="approveData.specialRelease" style="width: 100%">
  201. <el-option label="否" value="N"></el-option>
  202. <el-option label="是" value="Y"></el-option>
  203. </el-select>
  204. </el-form-item>
  205. </el-col>
  206. </el-row>
  207. <el-form-item label="审批意见">
  208. <el-input type="textarea" v-model="approveData.comment" :rows="3" placeholder="请输入审批意见"></el-input>
  209. </el-form-item>
  210. </el-form>
  211. <el-footer style="height:40px;margin-top: 60px;text-align:center">
  212. <el-button type="success" @click="submitApprove('APPROVED')" :loading="approveLoading">同意</el-button>
  213. <el-button type="danger" @click="submitApprove('REJECTED')" :loading="approveLoading">驳回</el-button>
  214. <el-button @click="approveDialogVisible = false" :disabled="approveLoading">取消</el-button>
  215. </el-footer>
  216. </el-dialog> -->
  217. </div>
  218. </template>
  219. <script>
  220. /* 组件 */
  221. import {
  222. searchPartList,
  223. createPart,
  224. updatePart,
  225. deletePart
  226. } from '@/api/part/partInfo.js'
  227. import excel from '@/utils/excel-util.js'
  228. import Chooselist from '@/views/modules/common/Chooselist_eam'
  229. import basicInfo from './com_part_BasicInfo'
  230. import specParams from './com_part_SpecParams'
  231. import suppliers from './com_part_Suppliers'
  232. import approval from './com_part_Approval'
  233. import attachments from './com_part_Attachments'
  234. import {
  235. approveNodeInstance,
  236. restartFlowInstance
  237. } from '@/api/workFlow/workFlow.js'
  238. export default {
  239. watch: {
  240. searchData: {
  241. deep: true,
  242. handler: function (newV, oldV) {
  243. this.searchData.partNo = this.searchData.partNo.toUpperCase()
  244. this.searchData.npc = this.searchData.npc.toUpperCase()
  245. this.searchData.category = this.searchData.category.toUpperCase()
  246. this.searchData.unit = this.searchData.unit.toUpperCase()
  247. this.searchData.codeNo = this.searchData.codeNo.toUpperCase()
  248. this.searchData.partDesc = this.searchData.partDesc.toUpperCase()
  249. this.searchData.partSpec = this.searchData.partSpec.toUpperCase()
  250. }
  251. },
  252. currentpart: {
  253. deep: true,
  254. handler: function (newV, oldV) {
  255. this.currentpart.partNo = this.currentpart.partNo.toUpperCase()
  256. this.currentpart.npc = this.currentpart.npc.toUpperCase()
  257. this.currentpart.category = this.currentpart.category.toUpperCase()
  258. this.currentpart.unit = this.currentpart.unit.toUpperCase()
  259. this.currentpart.codeNo = this.currentpart.codeNo.toUpperCase()
  260. this.currentpart.partDesc = this.currentpart.partDesc.toUpperCase()
  261. this.currentpart.partSpec = this.currentpart.partSpec.toUpperCase()
  262. }
  263. }
  264. },
  265. data () {
  266. return {
  267. functionId: this.$route.meta.menuId,
  268. height: 200,
  269. currentRow: {},
  270. searchData: {
  271. partNo: '',
  272. npc: '',
  273. partDesc: '',
  274. partSpec: '',
  275. buyerName: '',
  276. sourcingName: '',
  277. category: '',
  278. unit: '',
  279. status: '',
  280. codeNo: '',
  281. createBy: '',
  282. site: this.$store.state.user.site,
  283. page: 1,
  284. limit: 10
  285. },
  286. pageIndex: 1,
  287. pageSize: 50,
  288. totalPage: 0,
  289. tagNo: '',
  290. mainDataList: [],
  291. dataListLoading: false,
  292. activeName: 'basicInfo',
  293. // 审批对话框
  294. approveDialogVisible: false,
  295. approveLoading: false,
  296. approveData: {
  297. applyNo: '',
  298. // nodeCode: '',
  299. // nodeName: '',
  300. // departmentName: '', // 审批部门 - rqrq
  301. // assigneeName: '',
  302. site: '',
  303. orderType: '',
  304. comment: '',
  305. flowCode: '',
  306. flowVersion: null
  307. },
  308. columnArray1: [
  309. {
  310. userId: this.$store.state.user.name,
  311. functionId: this.functionId,
  312. serialNumber: 'partTablePartNo',
  313. tableId: 'partTable',
  314. tableName: '产品信息',
  315. columnProp: 'partNo',
  316. headerAlign: 'center',
  317. align: 'center',
  318. columnLabel: '产品编码',
  319. columnWidth: '100',
  320. columnHidden: false,
  321. columnImage: false,
  322. columnSortable: false,
  323. sortLv: 0,
  324. status: true,
  325. fixed: false
  326. },
  327. {
  328. userId: this.$store.state.user.name,
  329. functionId: this.functionId,
  330. serialNumber: 'partTableNpc',
  331. tableId: 'partTable',
  332. tableName: '产品信息',
  333. columnProp: 'npc',
  334. headerAlign: 'center',
  335. align: 'center',
  336. columnLabel: 'NPC货号',
  337. columnWidth: '100',
  338. columnHidden: false,
  339. columnImage: false,
  340. columnSortable: false,
  341. sortLv: 0,
  342. status: true,
  343. fixed: false
  344. },
  345. {
  346. userId: this.$store.state.user.name,
  347. functionId: this.functionId,
  348. serialNumber: 'partTablePartDesc',
  349. tableId: 'partTable',
  350. tableName: '产品信息',
  351. columnProp: 'partDesc',
  352. headerAlign: 'center',
  353. align: 'left',
  354. columnLabel: '产品名称',
  355. columnWidth: '200',
  356. columnHidden: false,
  357. columnImage: false,
  358. columnSortable: false,
  359. sortLv: 0,
  360. status: true,
  361. fixed: false
  362. },
  363. {
  364. userId: this.$store.state.user.name,
  365. functionId: this.functionId,
  366. serialNumber: 'partTablepartSpec',
  367. tableId: 'partTable',
  368. tableName: '产品信息',
  369. columnProp: 'partSpec',
  370. headerAlign: 'center',
  371. align: 'left',
  372. columnLabel: '产品规格',
  373. columnWidth: '150',
  374. columnHidden: false,
  375. columnImage: false,
  376. columnSortable: false,
  377. sortLv: 0,
  378. status: true,
  379. fixed: false
  380. },
  381. {
  382. userId: this.$store.state.user.name,
  383. functionId: this.functionId,
  384. serialNumber: 'partTableBuyerName',
  385. tableId: 'partTable',
  386. tableName: '产品信息',
  387. columnProp: 'buyerName',
  388. headerAlign: 'center',
  389. align: 'center',
  390. columnLabel: '采购员',
  391. columnWidth: '100',
  392. columnHidden: false,
  393. columnImage: false,
  394. columnSortable: false,
  395. sortLv: 0,
  396. status: true,
  397. fixed: false
  398. },
  399. {
  400. userId: this.$store.state.user.name,
  401. functionId: this.functionId,
  402. serialNumber: 'partTableSourcingName',
  403. tableId: 'partTable',
  404. tableName: '产品信息',
  405. columnProp: 'sourcingName',
  406. headerAlign: 'center',
  407. align: 'center',
  408. columnLabel: 'sourcing专员',
  409. columnWidth: '100',
  410. columnHidden: false,
  411. columnImage: false,
  412. columnSortable: false,
  413. sortLv: 0,
  414. status: true,
  415. fixed: false
  416. },
  417. {
  418. userId: this.$store.state.user.name,
  419. functionId: this.functionId,
  420. serialNumber: 'partTableCategory',
  421. tableId: 'partTable',
  422. tableName: '产品信息',
  423. columnProp: 'category',
  424. headerAlign: 'center',
  425. align: 'center',
  426. columnLabel: '产品分类',
  427. columnWidth: '100',
  428. columnHidden: false,
  429. columnImage: false,
  430. columnSortable: false,
  431. sortLv: 0,
  432. status: true,
  433. fixed: false
  434. },
  435. {
  436. userId: this.$store.state.user.name,
  437. functionId: this.functionId,
  438. serialNumber: 'partTableUnit',
  439. tableId: 'partTable',
  440. tableName: '产品信息',
  441. columnProp: 'unit',
  442. headerAlign: 'center',
  443. align: 'center',
  444. columnLabel: '计量单位',
  445. columnWidth: '80',
  446. columnHidden: false,
  447. columnImage: false,
  448. columnSortable: false,
  449. sortLv: 0,
  450. status: true,
  451. fixed: false
  452. },
  453. {
  454. userId: this.$store.state.user.name,
  455. functionId: this.functionId,
  456. serialNumber: 'partTablePartStage',
  457. tableId: 'partTable',
  458. tableName: '产品信息',
  459. columnProp: 'partStage',
  460. headerAlign: 'center',
  461. align: 'center',
  462. columnLabel: '物料阶段',
  463. columnWidth: '100',
  464. columnHidden: false,
  465. columnImage: false,
  466. columnSortable: false,
  467. sortLv: 0,
  468. status: true,
  469. fixed: false
  470. },
  471. {
  472. userId: this.$store.state.user.name,
  473. functionId: this.functionId,
  474. serialNumber: 'partTableStatus',
  475. tableId: 'partTable',
  476. tableName: '产品信息',
  477. columnProp: 'status',
  478. headerAlign: 'center',
  479. align: 'center',
  480. columnLabel: '状态',
  481. columnWidth: '80',
  482. columnHidden: false,
  483. columnImage: false,
  484. columnSortable: false,
  485. sortLv: 0,
  486. status: true,
  487. fixed: false
  488. },
  489. {
  490. userId: this.$store.state.user.name,
  491. functionId: this.functionId,
  492. serialNumber: 'partTableCodeNo',
  493. tableId: 'partTable',
  494. tableName: '产品信息',
  495. columnProp: 'codeNo',
  496. headerAlign: 'center',
  497. align: 'center',
  498. columnLabel: '属性模板',
  499. columnWidth: '100',
  500. columnHidden: false,
  501. columnImage: false,
  502. columnSortable: false,
  503. sortLv: 0,
  504. status: true,
  505. fixed: false
  506. },
  507. {
  508. userId: this.$store.state.user.name,
  509. functionId: this.functionId,
  510. serialNumber: 'partTableCreateBy',
  511. tableId: 'partTable',
  512. tableName: '产品信息',
  513. columnProp: 'createBy',
  514. headerAlign: 'center',
  515. align: 'center',
  516. columnLabel: '创建人',
  517. columnWidth: '100',
  518. columnHidden: false,
  519. columnImage: false,
  520. columnSortable: false,
  521. sortLv: 0,
  522. status: true,
  523. fixed: false
  524. }
  525. // {
  526. // userId: this.$store.state.user.name,
  527. // functionId: this.functionId,
  528. // serialNumber: 'partTableDepartmentName',
  529. // tableId: 'partTable',
  530. // tableName: '产品信息',
  531. // columnProp: 'departmentName',
  532. // headerAlign: 'center',
  533. // align: 'center',
  534. // columnLabel: '审批部门',
  535. // columnWidth: '100',
  536. // columnHidden: false,
  537. // columnImage: false,
  538. // columnSortable: false,
  539. // sortLv: 0,
  540. // status: true,
  541. // fixed: false
  542. // },
  543. // {
  544. // userId: this.$store.state.user.name,
  545. // functionId: this.functionId,
  546. // serialNumber: 'partTableApproverName',
  547. // tableId: 'partTable',
  548. // tableName: '产品信息',
  549. // columnProp: 'assigneeName',
  550. // headerAlign: 'center',
  551. // align: 'center',
  552. // columnLabel: '要求审批人',
  553. // columnWidth: '100',
  554. // columnHidden: false,
  555. // columnImage: false,
  556. // columnSortable: false,
  557. // sortLv: 0,
  558. // status: true,
  559. // fixed: false
  560. // },
  561. // {
  562. // userId: this.$store.state.user.name,
  563. // functionId: this.functionId,
  564. // serialNumber: 'partTableFlowStatus',
  565. // tableId: 'partTable',
  566. // tableName: '产品信息',
  567. // columnProp: 'flowStatus',
  568. // headerAlign: 'center',
  569. // align: 'center',
  570. // columnLabel: '审批状态',
  571. // columnWidth: '100',
  572. // columnHidden: false,
  573. // columnImage: false,
  574. // columnSortable: false,
  575. // sortLv: 0,
  576. // status: true,
  577. // fixed: false
  578. // }
  579. ],
  580. exportName: '产品信息' + this.dayjs().format('YYYYMMDDHHmmss'),
  581. // 产品对话框相关
  582. partDialogVisible: false,
  583. isAdd: true,
  584. currentpart: {
  585. partNo: '',
  586. npc: '',
  587. partDesc: '',
  588. partSpec: '',
  589. buyerName: '',
  590. sourcingName: '',
  591. category: '',
  592. unit: '',
  593. status: 'N',
  594. codeNo: '',
  595. createBy: '',
  596. remark: '',
  597. site: this.$store.state.user.site,
  598. },
  599. partRules: {
  600. partNo: [
  601. { required: true, message: ' ', trigger: 'blur' }
  602. ],
  603. partDesc: [
  604. { required: true, message: ' ', trigger: 'blur' }
  605. ],
  606. npc: [
  607. { required: true, message: ' ', trigger: 'blur' }
  608. ],
  609. partSpec: [
  610. { required: true, message: ' ', trigger: 'blur' }
  611. ]
  612. }
  613. }
  614. },
  615. /* 组件 */
  616. components: {
  617. Chooselist,
  618. basicInfo,
  619. specParams,
  620. suppliers,
  621. approval,
  622. attachments
  623. },
  624. created() {
  625. this.getMainData()
  626. },
  627. mounted () {
  628. this.$nextTick(() => {
  629. this.height = (window.innerHeight - 280) / 2
  630. })
  631. },
  632. methods: {
  633. formatPartStageDesc (partStage) {
  634. return partStage === 'Approved' ? '正式物料' : '新增物料'
  635. },
  636. getBaseList (val, type) {
  637. this.tagNo = val
  638. this.$nextTick(() => {
  639. let strVal = ''
  640. if (val === 1100) {
  641. strVal = this.searchData.partNo
  642. }
  643. if (this.tagNo === 526) {
  644. strVal = this.currentpart.category
  645. }
  646. if (this.tagNo === 510) {
  647. strVal = this.currentpart.unit
  648. }
  649. if (val === 529) {
  650. strVal = this.currentpart.buyerName
  651. }
  652. if (val === 528) {
  653. strVal = this.currentpart.sourcingName
  654. }
  655. if (val === 527) {
  656. strVal = this.currentpart.codeNo
  657. }
  658. this.$refs.baseList.init(val, strVal?strVal:'')
  659. })
  660. },
  661. /* 列表方法的回调 */
  662. getBaseData (val) {
  663. if (this.tagNo === 1100) {
  664. this.searchData.partNo = val.part_no
  665. }
  666. if (this.tagNo === 526) {
  667. this.currentpart.category = val.family_id
  668. }
  669. if (this.tagNo === 510) {
  670. this.currentpart.unit = val.UMID
  671. }
  672. if (this.tagNo === 529) {
  673. this.currentpart.buyerName = val.UserName
  674. }
  675. if (this.tagNo === 528) {
  676. this.currentpart.sourcingName = val.UserName
  677. }
  678. if (this.tagNo === 527) {
  679. this.currentpart.codeNo = val.code_no
  680. }
  681. },
  682. getMainData () {
  683. this.searchData.limit = this.pageSize
  684. this.searchData.page = this.pageIndex
  685. searchPartList(this.searchData).then(({data}) => {
  686. if (data.code === 0) {
  687. // 处理列表数据,确保可以正确显示嵌套属性
  688. this.mainDataList = data.page.list.map(item => {
  689. // 方式1:将嵌套属性提取到顶层
  690. if (item.flowNodeInstanceData) {
  691. item.departmentName = item.flowNodeInstanceData.departmentName;
  692. item.assigneeName = item.flowNodeInstanceData.assigneeName;
  693. } else {
  694. item.departmentName = '';
  695. item.assigneeName = '';
  696. }
  697. return item;
  698. });
  699. // this.mainDataList = data.page.list
  700. this.pageIndex = data.page.currPage
  701. this.pageSize = data.page.pageSize
  702. this.totalPage = data.page.totalCount
  703. // 判断是否全部存在数据
  704. if (this.mainDataList.length > 0) {
  705. // 设置选中行
  706. this.$refs.mainTable.setCurrentRow(this.mainDataList[0])
  707. this.changeData(this.mainDataList[0])
  708. } else {
  709. this.changeData(null)
  710. }
  711. }
  712. this.dataListLoading = false
  713. })
  714. },
  715. tabClick (tab, event) {
  716. this.refreshCurrentTabTable()
  717. },
  718. // 每页数
  719. sizeChangeHandle (val) {
  720. this.pageSize = val
  721. this.pageIndex = 1
  722. this.getMainData()
  723. },
  724. // 当前页
  725. currentChangeHandle (val) {
  726. this.pageIndex = val
  727. this.getMainData()
  728. },
  729. changeData (row) {
  730. this.currentRow = JSON.parse(JSON.stringify(row))
  731. this.refreshCurrentTabTable()
  732. },
  733. refreshCurrentTabTable () {
  734. if (this.currentRow === '' || this.currentRow === null) {
  735. this.currentRow = {site: '', partNo: ''}
  736. }
  737. if (this.activeName === 'basicInfo') {
  738. this.refreshBasicInfo()
  739. }
  740. if (this.activeName === 'specParams') {
  741. this.refreshSpecParams()
  742. }
  743. if (this.activeName === 'suppliers') {
  744. this.refreshSuppliers()
  745. }
  746. if (this.activeName === 'approval') {
  747. this.refreshApproval()
  748. }
  749. if (this.activeName === 'attachments') {
  750. this.refreshAttachments()
  751. }
  752. },
  753. async exportExcel () {
  754. this.searchData.limit = -1
  755. this.searchData.page = 1
  756. excel.exportTable({
  757. url: '/part/searchPartList',
  758. columnMapping: this.columnArray1,
  759. mergeSetting: [],
  760. params: this.searchData,
  761. fileName: this.exportName + '.xlsx',
  762. rowFetcher: res => res.data,
  763. columnFormatter: [
  764. { columnProp: 'partStage', formatter: (val) => this.formatPartStageDesc(val) }
  765. ],
  766. dropColumns: []
  767. })
  768. },
  769. refreshBasicInfo () {
  770. let inData = {
  771. site: this.currentRow.site,
  772. partNo: this.currentRow.partNo,
  773. partDesc: this.currentRow.partDesc,
  774. height: Number(this.height) - 20
  775. }
  776. this.$refs.basicInfo.init(inData)
  777. },
  778. refreshSpecParams () {
  779. let inData = {
  780. site: this.currentRow.site,
  781. partNo: this.currentRow.partNo,
  782. codeNo: this.currentRow.codeNo,
  783. functionType:"P",
  784. height: Number(this.height) - 20
  785. }
  786. this.$refs.specParams.init(inData)
  787. },
  788. refreshSuppliers () {
  789. let inData = {
  790. site: this.currentRow.site,
  791. partNo: this.currentRow.partNo,
  792. height: Number(this.height) - 20
  793. }
  794. this.$refs.suppliers.init(inData)
  795. },
  796. refreshApproval () {
  797. let inData = {
  798. site: this.currentRow.site,
  799. orderRef1: this.currentRow.partNo,
  800. orderType: '产品资料',
  801. height: Number(this.height) - 20
  802. }
  803. this.$refs.approval.init(inData)
  804. },
  805. refreshAttachments () {
  806. let inData = {
  807. orderRef1: this.currentRow.site,
  808. orderRef2: this.currentRow.partNo,
  809. orderRef3: this.currentRow.partDesc,
  810. orderReftype: 'part',
  811. height: Number(this.height) - 20
  812. }
  813. this.$refs.attachments.init(inData)
  814. },
  815. // 新增产品
  816. addPart() {
  817. this.isAdd = true
  818. this.currentpart = {
  819. partNo: '',
  820. npc: '',
  821. partDesc: '',
  822. partSpec: '',
  823. buyerName: '',
  824. sourcingName: '',
  825. category: '',
  826. unit: '',
  827. status: 'N',
  828. codeNo: '',
  829. createBy: this.$store.state.user.name,
  830. remark: '',
  831. site: this.$store.state.user.site,
  832. }
  833. this.partDialogVisible = true
  834. },
  835. // 编辑产品
  836. editPart(row) {
  837. if (!row) {
  838. this.$message.warning('请选择一个产品修改')
  839. return
  840. }
  841. this.isAdd = false
  842. this.currentpart = {...row}
  843. this.partDialogVisible = true
  844. },
  845. // 保存产品
  846. savePart() {
  847. this.$refs.partForm.validate((valid) => {
  848. if (valid) {
  849. const apiCall = this.isAdd ? createPart(this.currentpart) : updatePart(this.currentpart)
  850. apiCall.then(({data}) => {
  851. if (data && data.code === 0) {
  852. this.$message.success(this.isAdd ? '新增产品成功' : '修改产品成功')
  853. this.partDialogVisible = false
  854. this.getMainData()
  855. } else {
  856. this.$message.error(data.msg || '操作失败')
  857. }
  858. }).catch(error => {
  859. this.$message.error('操作失败: ' + error.message)
  860. })
  861. } else {
  862. this.$message.warning('请填写必填字段')
  863. }
  864. })
  865. },
  866. // 删除产品
  867. deletePart(row) {
  868. this.$confirm('你确定删除该产品?', '确认删除', {
  869. confirmButtonText: '确认',
  870. cancelButtonText: '取消',
  871. type: 'warning'
  872. }).then(() => {
  873. deletePart(row.id).then(({data}) => {
  874. if (data && data.code === 0) {
  875. this.$message.success('产品删除成功')
  876. this.getMainData()
  877. } else {
  878. this.$message.error(data.msg || '删除失败')
  879. }
  880. }).catch(error => {
  881. this.$message.error('删除失败: ' + error.message)
  882. })
  883. })
  884. }
  885. // 打开审批对话框
  886. // openApproveDialog(row) {
  887. // this.approveData = {
  888. // applyNo: row.flowNodeInstanceData.applyNo,
  889. // site: row.flowNodeInstanceData.site,
  890. // orderType: row.flowNodeInstanceData.orderType,
  891. // flowCode: row.flowNodeInstanceData.flowCode,
  892. // flowVersion: row.flowNodeInstanceData.flowVersion,
  893. // nodeCode: row.flowNodeInstanceData.nodeCode,
  894. // comment: ''
  895. // }
  896. // this.approveDialogVisible = true
  897. // },
  898. // 提交审批
  899. // submitApprove(action) {
  900. // if (action === 'REJECTED' && !this.approveData.comment) {
  901. // this.$message.warning('驳回时必须填写审批意见')
  902. // return
  903. // }
  904. // this.approveLoading = true
  905. // approveNodeInstance({
  906. // applyNo: this.approveData.applyNo,
  907. // nodeCode: this.approveData.nodeCode,
  908. // site: this.approveData.site,
  909. // orderType: this.approveData.orderType,
  910. // specialRelease: this.approveData.specialRelease,
  911. // action: action,
  912. // comment: this.approveData.comment
  913. // }).then(({ data }) => {
  914. // if (data && data.code === 0) {
  915. // this.$message.success(action === 'APPROVED' ? '审批通过成功' : '驳回成功')
  916. // this.approveDialogVisible = false
  917. // //刷新列表
  918. // this.getMainData()
  919. // } else {
  920. // this.$message.error(data.msg || '操作失败')
  921. // }
  922. // }).finally(() => {
  923. // this.approveLoading = false
  924. // })
  925. // },
  926. // 重新审批 - rqrq
  927. // handleRestart(row) {
  928. // this.$confirm('确定要重新发起审批流程吗?', '提示', {
  929. // confirmButtonText: '确定',
  930. // cancelButtonText: '取消',
  931. // type: 'warning'
  932. // }).then(() => {
  933. // restartFlowInstance({
  934. // applyNo: row.applyNo,
  935. // site: row.site,
  936. // orderType: row.orderType
  937. // }).then(({ data }) => {
  938. // if (data && data.code === 0) {
  939. // this.$message.success('重新审批成功')
  940. // this.getMainData()
  941. // } else {
  942. // this.$message.error(data.msg || '操作失败')
  943. // }
  944. // })
  945. // }).catch(() => {})
  946. // }
  947. }
  948. }
  949. </script>
  950. <!--当前页面的标签样式-->
  951. <style scoped lang="scss">
  952. /deep/ .customer-tab .el-tabs__content {
  953. padding: 5px !important;
  954. }
  955. /* 产品对话框整体样式 */
  956. .part-dialog {
  957. font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  958. }
  959. .part-dialog .el-dialog {
  960. margin-top: 5vh !important;
  961. margin-bottom: 5vh !important;
  962. }
  963. .part-dialog .el-dialog__header {
  964. padding: 20px 25px 15px 25px;
  965. border-bottom: 1px solid #E4E7ED;
  966. }
  967. .part-dialog .el-dialog__body {
  968. padding: 25px 25px 25px 25px;
  969. max-height: 75vh;
  970. overflow-y: auto;
  971. min-height: 400px;
  972. }
  973. .dialog-content {
  974. width: 100%;
  975. }
  976. /* 产品表单样式 */
  977. .part-form {
  978. width: 100%;
  979. }
  980. .part-form .el-form-item {
  981. margin-bottom: 1px;
  982. }
  983. .part-form .el-form-item__label {
  984. font-weight: 500;
  985. color: #303133;
  986. line-height: 32px;
  987. padding-right: 12px;
  988. }
  989. .part-form .el-form-item__content {
  990. line-height: normal;
  991. }
  992. /* 表单分组样式 */
  993. .form-section {
  994. margin-bottom: 5px;
  995. }
  996. .form-section:last-child {
  997. margin-bottom: 5px;
  998. }
  999. /* 输入框样式 */
  1000. .part-form .el-input,
  1001. .part-form .el-textarea,
  1002. .part-form .el-date-editor {
  1003. width: 100%;
  1004. }
  1005. /* 文本域样式优化 */
  1006. .part-form .el-textarea__inner {
  1007. resize: none;
  1008. font-family: inherit;
  1009. line-height: 1.5;
  1010. }
  1011. /* 对话框底部按钮居中 */
  1012. .dialog-footer-center {
  1013. text-align: center;
  1014. padding: 15px 0 5px 0;
  1015. border-top: 1px solid #E4E7ED;
  1016. margin-top: 15px;
  1017. }
  1018. .dialog-footer-center .el-button {
  1019. margin: 0 10px;
  1020. min-width: 90px;
  1021. height: 36px;
  1022. padding: 0 20px;
  1023. font-size: 14px;
  1024. }
  1025. /* 响应式调整 */
  1026. @media (max-width: 1200px) {
  1027. .part-dialog {
  1028. width: 95% !important;
  1029. }
  1030. .part-dialog .el-dialog__body {
  1031. padding: 20px 20px 15px 20px;
  1032. }
  1033. }
  1034. @media (max-width: 768px) {
  1035. .part-form .el-col {
  1036. margin-bottom: 20px;
  1037. }
  1038. .form-section {
  1039. margin-bottom: 35px;
  1040. }
  1041. .part-form .el-form-item__label {
  1042. line-height: 28px;
  1043. height: 28px;
  1044. }
  1045. }
  1046. </style>