product-management.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  1. <!-- BOM清单 -->
  2. <template>
  3. <div class="product-management">
  4. <template v-if="!addOrUpdateVisible && !changeFormVisible && !attachVisible && !detailVisible && !craftsVisible && !drawVisible && !changeVisible && !noticeChangeVisible && !importVisible">
  5. <el-form :inline="true" :model="dataForm" @keyup.enter.native="search()">
  6. <el-form-item label="名称">
  7. <el-input v-model="dataForm.productName" placeholder="物料名称" clearable/>
  8. </el-form-item>
  9. <el-form-item label="物料类别">
  10. <el-select
  11. v-model="dataForm.productType"
  12. remote
  13. placeholder="请选择">
  14. <el-option
  15. v-for="item in optionsType"
  16. :key="item.code"
  17. :label="item.value"
  18. :value="item.code">
  19. </el-option>
  20. </el-select>
  21. </el-form-item>
  22. <el-form-item label="图号">
  23. <el-input v-model="dataForm.mapNumber" placeholder="图号" clearable/>
  24. </el-form-item>
  25. <el-form-item>
  26. <el-button @click="search()">查询</el-button>
  27. <el-button v-if="isAuth('pro:product:save')" type="primary" @click="addOrUpdateHandle(0, false)">新建</el-button>
  28. <el-button v-if="isAuth('pro:product:noteChangeConfig')" type="primary" @click="setNoticeChangeHandel()">变更通知人设置</el-button>
  29. <el-button type="primary" @click="importFromExcel">导入清单</el-button>
  30. <el-button type="primary" @click="templateDownload">清单模板下载</el-button>
  31. </el-form-item>
  32. </el-form>
  33. <el-table
  34. :data="dataList"
  35. border
  36. v-loading="dataListLoading"
  37. style="width: 100%;">
  38. <el-table-column
  39. label="序号"
  40. type="index"
  41. width="50"
  42. align="center">
  43. </el-table-column>
  44. <el-table-column
  45. prop="productCode"
  46. header-align="center"
  47. align="center"
  48. width="140"
  49. :show-tooltip-when-overflow="true"
  50. label="物料编码">
  51. </el-table-column>
  52. <el-table-column
  53. prop="productType"
  54. header-align="center"
  55. align="center"
  56. min-width="120"
  57. :formatter="typeFormat"
  58. label="类别">
  59. </el-table-column>
  60. <el-table-column
  61. prop="isCompose"
  62. header-align="center"
  63. align="center"
  64. min-width="80"
  65. :formatter="composeFormat"
  66. label="是否组合">
  67. </el-table-column>
  68. <el-table-column
  69. prop="mapNumber"
  70. header-align="center"
  71. align="center"
  72. width="120"
  73. :show-tooltip-when-overflow="true"
  74. label="图号">
  75. </el-table-column>
  76. <el-table-column
  77. prop="productName"
  78. header-align="center"
  79. align="center"
  80. width="140"
  81. :show-tooltip-when-overflow="true"
  82. label="物料名称">
  83. </el-table-column>
  84. <el-table-column
  85. prop="productSpec"
  86. header-align="center"
  87. align="center"
  88. width="140"
  89. :show-tooltip-when-overflow="true"
  90. label="物料规格">
  91. </el-table-column>
  92. <el-table-column
  93. prop="materials"
  94. header-align="center"
  95. align="center"
  96. width="140"
  97. :show-tooltip-when-overflow="true"
  98. label="材料">
  99. </el-table-column>
  100. <el-table-column
  101. prop="cnt"
  102. header-align="center"
  103. align="center"
  104. label="单套数量">
  105. </el-table-column>
  106. <el-table-column
  107. prop="unit"
  108. header-align="center"
  109. align="center"
  110. label="单位">
  111. </el-table-column>
  112. <el-table-column
  113. prop="size"
  114. header-align="center"
  115. align="center"
  116. label="物料尺寸">
  117. </el-table-column>
  118. <el-table-column
  119. prop="developedSize"
  120. header-align="center"
  121. align="center"
  122. width="100"
  123. :show-tooltip-when-overflow="true"
  124. label="展开尺寸">
  125. </el-table-column>
  126. <el-table-column
  127. prop="surfaceTreatment"
  128. header-align="center"
  129. align="center"
  130. width="100"
  131. :show-tooltip-when-overflow="true"
  132. label="表面处理">
  133. </el-table-column>
  134. <el-table-column
  135. prop="sourceName"
  136. header-align="center"
  137. align="center"
  138. width="160"
  139. :show-overflow-tooltip="true"
  140. label="来源">
  141. </el-table-column>
  142. <el-table-column
  143. header-align="center"
  144. align="center"
  145. width="140"
  146. :show-overflow-tooltip="true"
  147. label="更改说明">
  148. <template slot-scope="scope">
  149. <span>{{scope.row.noticeChangeRecord?scope.row.noticeChangeRecord.description:''}}</span>
  150. </template>
  151. </el-table-column>
  152. <el-table-column
  153. header-align="center"
  154. align="center"
  155. label="更改单">
  156. <template slot-scope="scope">
  157. <el-button :disabled="!scope.row.noticeChangeRecord || !scope.row.noticeChangeRecord.attachList || scope.row.noticeChangeRecord.attachList.length === 0" type="text" size="small" @click="changeDetails(scope.row)">查看</el-button>
  158. </template>
  159. </el-table-column>
  160. <el-table-column
  161. header-align="center"
  162. align="center"
  163. label="技术文件">
  164. <template slot-scope="scope">
  165. <el-button :disabled="!scope.row.attachList || scope.row.attachList.length === 0" type="text" size="small" @click="attachDetails(scope.row)">查看</el-button>
  166. </template>
  167. </el-table-column>
  168. <el-table-column
  169. header-align="center"
  170. align="center"
  171. label="物料配料清单">
  172. <template slot-scope="scope">
  173. <el-button :disabled="!scope.row.listingList || scope.row.listingList.length === 0" type="text" size="small" @click="attachDetails2(scope.row)">查看</el-button>
  174. </template>
  175. </el-table-column>
  176. <el-table-column
  177. header-align="center"
  178. align="center"
  179. label="对应图纸">
  180. <template slot-scope="scope">
  181. <el-button :disabled="!scope.row.proDrawings || scope.row.proDrawings.length === 0" type="text" size="small" @click="drawDetails(scope.row)">查看</el-button>
  182. </template>
  183. </el-table-column>
  184. <el-table-column
  185. header-align="center"
  186. align="center"
  187. label="对应工艺">
  188. <template slot-scope="scope">
  189. <el-button :disabled="!scope.row.techId" type="text" size="small" @click="techDetails(scope.row.techId)">查看</el-button>
  190. </template>
  191. </el-table-column>
  192. <el-table-column
  193. prop="createTime"
  194. header-align="center"
  195. align="center"
  196. min-width="160"
  197. label="创建时间">
  198. </el-table-column>
  199. <el-table-column
  200. prop="creatorName"
  201. header-align="center"
  202. align="center"
  203. min-width="100"
  204. label="创建人">
  205. </el-table-column>
  206. <el-table-column
  207. prop="notes"
  208. header-align="center"
  209. align="center"
  210. min-width="180"
  211. :show-overflow-tooltip="true"
  212. label="备注">
  213. </el-table-column>
  214. <el-table-column
  215. fixed="right"
  216. header-align="center"
  217. align="center"
  218. min-width="80"
  219. :formatter="formatState"
  220. :show-overflow-tooltip="true"
  221. label="状态">
  222. </el-table-column>
  223. <el-table-column
  224. fixed="right"
  225. header-align="center"
  226. align="center"
  227. min-width="80"
  228. :formatter="formatReadState"
  229. :show-overflow-tooltip="true"
  230. label="读写状态">
  231. </el-table-column>
  232. <el-table-column
  233. fixed="right"
  234. header-align="center"
  235. align="center"
  236. width="240"
  237. label="操作">
  238. <template slot-scope="scope">
  239. <el-button v-if="isAuth('pro:product:info')" type="text" size="small" @click="detailHandle(scope.row.productId)">查看</el-button>
  240. <el-button v-if="isAuth('pro:product:update')" type="text" size="small" @click="addOrUpdateHandle(scope.row.productId, false)">编辑</el-button>
  241. <el-button v-if="isAuth('pro:product:change')" type="text" size="small" @click="changeHandle(scope.row.productId)">变更</el-button>
  242. <el-button v-if="isAuth('pro:product:read') && Number(scope.row.writeState) === 2" type="text" size="small" @click="readHandle(scope.row.productId)">只读</el-button>
  243. <el-button v-if="isAuth('pro:product:write') && Number(scope.row.writeState) === 1" type="text" size="small" @click="writeHandle(scope.row.productId)">读写</el-button>
  244. <el-button v-if="isAuth('pro:product:pause') && Number(scope.row.state) === 1" type="text" size="small" @click="pauseHandle(scope.row.productId)">暂停生产</el-button>
  245. <el-button v-if="isAuth('pro:product:regain') && Number(scope.row.state) === 2" type="text" size="small" @click="regainHandle(scope.row.productId)">恢复生产</el-button>
  246. </template>
  247. </el-table-column>
  248. </el-table>
  249. <el-pagination
  250. @size-change="sizeChangeHandle"
  251. @current-change="currentChangeHandle"
  252. :current-page="pageIndex"
  253. :page-sizes="[10, 20, 50, 100]"
  254. :page-size="pageSize"
  255. :total="totalPage"
  256. layout="total, sizes, prev, pager, next, jumper">
  257. </el-pagination>
  258. </template>
  259. <!-- 弹窗, 新增 / 修改 -->
  260. <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList" @onChose="onChose"></add-or-update>
  261. <detail v-if="detailVisible" ref="detail" @onChose="onChose"/>
  262. <crafts-detail v-if="craftsVisible" ref="craftsDetail" @onChose="onChose"/>
  263. <product-draw-detail v-if="drawVisible" ref="drawDetail" @onChose="onChose"/>
  264. <attach-detail v-if="changeVisible" ref="changeDetail" @onChose="onChose"/>
  265. <attach-detail v-if="attachVisible" ref="attachDetail" @onChose="onChose"/>
  266. <notice-change-setting v-if="noticeChangeVisible" ref="noticeChangeSetting" @onChose="onChose"/>
  267. <change-form v-if="changeFormVisible" ref="changeForm" @refreshDataList="getDataList" @onChose="onChose"/>
  268. <el-dialog title="导入清单" :visible.sync="importVisible">
  269. <el-upload
  270. class="upload-demo"
  271. ref="upload"
  272. :on-remove="handleRemove"
  273. action="#"
  274. :limit="1"
  275. :file-list="fileList"
  276. :auto-upload="false"
  277. :http-request="handleUpload"
  278. v-loading="importLoading"
  279. >
  280. <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
  281. <el-button size="small" type="success" @click="submitUpload" >开始上传</el-button>
  282. </el-upload>
  283. </el-dialog>
  284. </div>
  285. </template>
  286. <script>
  287. import Vue from 'vue'
  288. import AddOrUpdate from './product-add-or-update'
  289. import Detail from './product-detail'
  290. import { getDictList } from '@/api/dict'
  291. import { getProductList } from '@/api/product'
  292. import CraftsDetail from './crafts-detail'
  293. import ProductDrawDetail from './product-draw-detail'
  294. import AttachDetail from '../common/attach-detail'
  295. import NoticeChangeSetting from './product-notice-change-setting'
  296. import ChangeForm from './product-change'
  297. import {bomStateOption, writeStateOption} from '@/utils/enums'
  298. import UploadComponent from '@/views/modules/common/upload-component-v2'
  299. export default {
  300. name: 'product-management',
  301. components: {
  302. AttachDetail,
  303. ProductDrawDetail,
  304. CraftsDetail,
  305. AddOrUpdate,
  306. Detail,
  307. NoticeChangeSetting,
  308. ChangeForm,
  309. UploadComponent
  310. },
  311. data () {
  312. return {
  313. addOrUpdateVisible: false,
  314. attachVisible: false,
  315. detailVisible: false,
  316. craftsVisible: false,
  317. drawVisible: false,
  318. changeVisible: false,
  319. noticeChangeVisible: false,
  320. changeFormVisible: false,
  321. importVisible: false,
  322. dataForm: {},
  323. dataList: [],
  324. pageIndex: 1,
  325. pageSize: 10,
  326. totalPage: 0,
  327. dataListLoading: false,
  328. dataListSelections: [],
  329. optionsType: [],
  330. bomStateOption: bomStateOption,
  331. writeStateOption: writeStateOption,
  332. importForm: {},
  333. importLoading: false,
  334. fileList: []
  335. }
  336. },
  337. created () {
  338. this.getTypeList()
  339. // this.getStateList()
  340. this.getDataList()
  341. },
  342. methods: {
  343. onChose () {
  344. this.addOrUpdateVisible = false
  345. this.attachVisible = false
  346. this.detailVisible = false
  347. this.craftsVisible = false
  348. this.drawVisible = false
  349. this.changeVisible = false
  350. this.noticeChangeVisible = false
  351. this.changeFormVisible = false
  352. },
  353. // 获取物料类别字典
  354. getTypeList () {
  355. getDictList({type: 'product_type'}).then(({data}) => {
  356. if (data) {
  357. this.optionsType = data
  358. }
  359. })
  360. },
  361. // 查询
  362. search () {
  363. this.pageIndex = 1
  364. this.getDataList()
  365. },
  366. // 获取数据列表
  367. getDataList () {
  368. this.dataListLoading = true
  369. this.addOrUpdateVisible = false
  370. let params = {
  371. ...this.dataForm,
  372. 'current': this.pageIndex,
  373. 'size': this.pageSize
  374. }
  375. getProductList(params).then(({data}) => {
  376. if (data && data.code === '200') {
  377. this.dataList = data.data.records
  378. this.totalPage = Number(data.data.total)
  379. } else {
  380. this.dataList = []
  381. this.totalPage = 0
  382. }
  383. this.dataListLoading = false
  384. })
  385. },
  386. deleteHandle (id) {
  387. if (!id) return
  388. let ids = []
  389. ids.push(id)
  390. this.$confirm(`确定删除?`, '提示', {
  391. confirmButtonText: '确定',
  392. cancelButtonText: '取消',
  393. type: 'warning'
  394. }).then(() => {
  395. this.$http({
  396. url: this.$http.adornUrl(`/biz-service/product/delete`),
  397. method: 'DELETE',
  398. data: ids
  399. }).then(({data}) => {
  400. if (data && data.code === '200') {
  401. this.$message({
  402. message: '操作成功',
  403. type: 'success',
  404. duration: 1500,
  405. onClose: () => {
  406. this.getDataList()
  407. }
  408. })
  409. } else {
  410. this.$message.error(data.msg)
  411. }
  412. })
  413. }).catch(() => {})
  414. },
  415. // 每页数
  416. sizeChangeHandle (val) {
  417. this.pageSize = val
  418. this.pageIndex = 1
  419. this.getDataList()
  420. },
  421. // 当前页
  422. currentChangeHandle (val) {
  423. this.pageIndex = val
  424. this.getDataList()
  425. },
  426. // 多选
  427. selectionChangeHandle (val) {
  428. this.dataListSelections = val
  429. },
  430. // 新增 / 修改
  431. addOrUpdateHandle (id, disable) {
  432. this.addOrUpdateVisible = true
  433. this.$nextTick(() => {
  434. this.$refs.addOrUpdate.init(id, disable)
  435. })
  436. },
  437. // 变更
  438. changeHandle (id) {
  439. this.changeFormVisible = true
  440. this.$nextTick(() => {
  441. this.$refs.changeForm.init(id)
  442. })
  443. },
  444. // 转换属性“物料类别”
  445. typeFormat (row) {
  446. if (this.optionsType) {
  447. for (let i = 0; i < this.optionsType.length; i++) {
  448. if (this.optionsType[i].code === row.productType) {
  449. return this.optionsType[i].value
  450. }
  451. }
  452. }
  453. },
  454. // 转换属性“是否组合物料”
  455. composeFormat (row) {
  456. if (!row.isCompose) return ''
  457. if (Number(row.isCompose) === 1) {
  458. return '是'
  459. } else return '否'
  460. },
  461. // 详情
  462. detailHandle (id) {
  463. this.detailVisible = true
  464. this.$nextTick(() => {
  465. this.$refs.detail.init(id)
  466. })
  467. },
  468. // 变更通知人设置
  469. setNoticeChangeHandel () {
  470. this.noticeChangeVisible = true
  471. this.$nextTick(() => {
  472. this.$refs.noticeChangeSetting.init()
  473. })
  474. },
  475. // 对应图纸
  476. drawDetails (row) {
  477. this.drawVisible = true
  478. this.$nextTick(() => {
  479. this.$refs.drawDetail.init(row.proDrawings)
  480. })
  481. },
  482. // 对应工艺
  483. techDetails (id) {
  484. this.craftsVisible = true
  485. this.$nextTick(() => {
  486. this.$refs.craftsDetail.init(id)
  487. })
  488. },
  489. // 物料更改通知单
  490. changeDetails (row) {
  491. this.changeVisible = true
  492. this.$nextTick(() => {
  493. this.$refs.changeDetail.init(row.noticeChangeRecord.attachList)
  494. })
  495. },
  496. // 物料技术文件
  497. attachDetails (row) {
  498. this.attachVisible = true
  499. this.$nextTick(() => {
  500. this.$refs.attachDetail.init(row.attachList)
  501. })
  502. },
  503. // 物料配料清单附件
  504. attachDetails2 (row) {
  505. this.attachVisible = true
  506. this.$nextTick(() => {
  507. this.$refs.attachDetail.init(row.listingList)
  508. })
  509. },
  510. // 状态
  511. formatState (row) {
  512. if (!row.state) return ''
  513. let option = this.bomStateOption.find(t => t.value === row.state)
  514. if (option != null) {
  515. return option.label
  516. }
  517. return ''
  518. },
  519. formatReadState (row) {
  520. if (!row.writeState) return ''
  521. let option = this.writeStateOption.find(t => t.value === row.writeState)
  522. if (option != null) {
  523. return option.label
  524. }
  525. return ''
  526. },
  527. pauseHandle (id) {
  528. if (!id) return
  529. this.$confirm(`确定暂停?`, '提示', {
  530. confirmButtonText: '确定',
  531. cancelButtonText: '取消',
  532. type: 'warning'
  533. }).then(() => {
  534. this.$http({
  535. url: this.$http.adornUrl(`/biz-service/product/pause`),
  536. method: 'POST',
  537. data: {id: id}
  538. }).then(({data}) => {
  539. if (data && data.code === '200') {
  540. this.$message({
  541. message: '操作成功',
  542. type: 'success',
  543. duration: 1500,
  544. onClose: () => {
  545. this.getDataList()
  546. }
  547. })
  548. } else {
  549. this.$message.error(data.msg)
  550. }
  551. })
  552. }).catch(() => {})
  553. },
  554. regainHandle (id) {
  555. if (!id) return
  556. this.$confirm(`确定恢复?`, '提示', {
  557. confirmButtonText: '确定',
  558. cancelButtonText: '取消',
  559. type: 'warning'
  560. }).then(() => {
  561. this.$http({
  562. url: this.$http.adornUrl(`/biz-service/product/regain`),
  563. method: 'POST',
  564. data: {id: id}
  565. }).then(({data}) => {
  566. if (data && data.code === '200') {
  567. this.$message({
  568. message: '操作成功',
  569. type: 'success',
  570. duration: 1500,
  571. onClose: () => {
  572. this.getDataList()
  573. }
  574. })
  575. } else {
  576. this.$message.error(data.msg)
  577. }
  578. })
  579. }).catch(() => {})
  580. },
  581. readHandle (id) {
  582. if (!id) return
  583. this.$confirm(`确定只读?`, '提示', {
  584. confirmButtonText: '确定',
  585. cancelButtonText: '取消',
  586. type: 'warning'
  587. }).then(() => {
  588. this.$http({
  589. url: this.$http.adornUrl(`/biz-service/product/read`),
  590. method: 'POST',
  591. data: {id: id}
  592. }).then(({data}) => {
  593. if (data && data.code === '200') {
  594. this.$message({
  595. message: '操作成功',
  596. type: 'success',
  597. duration: 1500,
  598. onClose: () => {
  599. this.getDataList()
  600. }
  601. })
  602. } else {
  603. this.$message.error(data.msg)
  604. }
  605. })
  606. }).catch(() => {})
  607. },
  608. writeHandle (id) {
  609. if (!id) return
  610. this.$confirm(`确定读写?`, '提示', {
  611. confirmButtonText: '确定',
  612. cancelButtonText: '取消',
  613. type: 'warning'
  614. }).then(() => {
  615. this.$http({
  616. url: this.$http.adornUrl(`/biz-service/product/write`),
  617. method: 'POST',
  618. data: {id: id}
  619. }).then(({data}) => {
  620. if (data && data.code === '200') {
  621. this.$message({
  622. message: '操作成功',
  623. type: 'success',
  624. duration: 1500,
  625. onClose: () => {
  626. this.getDataList()
  627. }
  628. })
  629. } else {
  630. this.$message.error(data.msg)
  631. }
  632. })
  633. }).catch(() => {})
  634. },
  635. importFromExcel () {
  636. this.importVisible = true
  637. },
  638. handleUpload (file) {
  639. if (file == null) {
  640. this.$message.error('请上传清单文件')
  641. return
  642. }
  643. this.importLoading = true
  644. const formData = new FormData()
  645. formData.append('importFile', file.file)
  646. this.$http({
  647. url: this.$http.adornUrl(`/biz-service/product/importExcel`),
  648. method: 'POST',
  649. data: formData
  650. }).then(({data}) => {
  651. this.importLoading = false
  652. if (data && data.code === '200') {
  653. this.$message({
  654. message: '导入成功',
  655. type: 'success',
  656. duration: 1500,
  657. onClose: () => {
  658. this.importVisible = false
  659. }
  660. })
  661. } else {
  662. this.$message.error(data.msg)
  663. }
  664. })
  665. },
  666. // 上传
  667. submitUpload () {
  668. this.$refs.upload.submit()
  669. },
  670. // 移除
  671. handleRemove (file, fileList) {
  672. this.$emit('input', fileList)
  673. },
  674. templateDownload () {
  675. location.href = this.$http.adornUrl(`/biz-service/product/template/download?_token=${Vue.cookie.get('token')}`)
  676. }
  677. }
  678. }
  679. </script>
  680. <style scoped>
  681. </style>