product-management.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  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. >
  279. <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
  280. <el-button size="small" type="success" @click="submitUpload">开始上传</el-button>
  281. </el-upload>
  282. </el-dialog>
  283. </div>
  284. </template>
  285. <script>
  286. import Vue from 'vue'
  287. import AddOrUpdate from './product-add-or-update'
  288. import Detail from './product-detail'
  289. import { getDictList } from '@/api/dict'
  290. import { getProductList } from '@/api/product'
  291. import CraftsDetail from './crafts-detail'
  292. import ProductDrawDetail from './product-draw-detail'
  293. import AttachDetail from '../common/attach-detail'
  294. import NoticeChangeSetting from './product-notice-change-setting'
  295. import ChangeForm from './product-change'
  296. import {bomStateOption, writeStateOption} from '@/utils/enums'
  297. import UploadComponent from '@/views/modules/common/upload-component-v2'
  298. export default {
  299. name: 'product-management',
  300. components: {
  301. AttachDetail,
  302. ProductDrawDetail,
  303. CraftsDetail,
  304. AddOrUpdate,
  305. Detail,
  306. NoticeChangeSetting,
  307. ChangeForm,
  308. UploadComponent
  309. },
  310. data () {
  311. return {
  312. addOrUpdateVisible: false,
  313. attachVisible: false,
  314. detailVisible: false,
  315. craftsVisible: false,
  316. drawVisible: false,
  317. changeVisible: false,
  318. noticeChangeVisible: false,
  319. changeFormVisible: false,
  320. importVisible: false,
  321. dataForm: {},
  322. dataList: [],
  323. pageIndex: 1,
  324. pageSize: 10,
  325. totalPage: 0,
  326. dataListLoading: false,
  327. dataListSelections: [],
  328. optionsType: [],
  329. bomStateOption: bomStateOption,
  330. writeStateOption: writeStateOption,
  331. importForm: {},
  332. fileList: []
  333. }
  334. },
  335. created () {
  336. this.getTypeList()
  337. // this.getStateList()
  338. this.getDataList()
  339. },
  340. methods: {
  341. onChose () {
  342. this.addOrUpdateVisible = false
  343. this.attachVisible = false
  344. this.detailVisible = false
  345. this.craftsVisible = false
  346. this.drawVisible = false
  347. this.changeVisible = false
  348. this.noticeChangeVisible = false
  349. this.changeFormVisible = false
  350. },
  351. // 获取物料类别字典
  352. getTypeList () {
  353. getDictList({type: 'product_type'}).then(({data}) => {
  354. if (data) {
  355. this.optionsType = data
  356. }
  357. })
  358. },
  359. // 查询
  360. search () {
  361. this.pageIndex = 1
  362. this.getDataList()
  363. },
  364. // 获取数据列表
  365. getDataList () {
  366. this.dataListLoading = true
  367. this.addOrUpdateVisible = false
  368. let params = {
  369. ...this.dataForm,
  370. 'current': this.pageIndex,
  371. 'size': this.pageSize
  372. }
  373. getProductList(params).then(({data}) => {
  374. if (data && data.code === '200') {
  375. this.dataList = data.data.records
  376. this.totalPage = Number(data.data.total)
  377. } else {
  378. this.dataList = []
  379. this.totalPage = 0
  380. }
  381. this.dataListLoading = false
  382. })
  383. },
  384. deleteHandle (id) {
  385. if (!id) return
  386. let ids = []
  387. ids.push(id)
  388. this.$confirm(`确定删除?`, '提示', {
  389. confirmButtonText: '确定',
  390. cancelButtonText: '取消',
  391. type: 'warning'
  392. }).then(() => {
  393. this.$http({
  394. url: this.$http.adornUrl(`/biz-service/product/delete`),
  395. method: 'DELETE',
  396. data: ids
  397. }).then(({data}) => {
  398. if (data && data.code === '200') {
  399. this.$message({
  400. message: '操作成功',
  401. type: 'success',
  402. duration: 1500,
  403. onClose: () => {
  404. this.getDataList()
  405. }
  406. })
  407. } else {
  408. this.$message.error(data.msg)
  409. }
  410. })
  411. }).catch(() => {})
  412. },
  413. // 每页数
  414. sizeChangeHandle (val) {
  415. this.pageSize = val
  416. this.pageIndex = 1
  417. this.getDataList()
  418. },
  419. // 当前页
  420. currentChangeHandle (val) {
  421. this.pageIndex = val
  422. this.getDataList()
  423. },
  424. // 多选
  425. selectionChangeHandle (val) {
  426. this.dataListSelections = val
  427. },
  428. // 新增 / 修改
  429. addOrUpdateHandle (id, disable) {
  430. this.addOrUpdateVisible = true
  431. this.$nextTick(() => {
  432. this.$refs.addOrUpdate.init(id, disable)
  433. })
  434. },
  435. // 变更
  436. changeHandle (id) {
  437. this.changeFormVisible = true
  438. this.$nextTick(() => {
  439. this.$refs.changeForm.init(id)
  440. })
  441. },
  442. // 转换属性“物料类别”
  443. typeFormat (row) {
  444. if (this.optionsType) {
  445. for (let i = 0; i < this.optionsType.length; i++) {
  446. if (this.optionsType[i].code === row.productType) {
  447. return this.optionsType[i].value
  448. }
  449. }
  450. }
  451. },
  452. // 转换属性“是否组合物料”
  453. composeFormat (row) {
  454. if (!row.isCompose) return ''
  455. if (Number(row.isCompose) === 1) {
  456. return '是'
  457. } else return '否'
  458. },
  459. // 详情
  460. detailHandle (id) {
  461. this.detailVisible = true
  462. this.$nextTick(() => {
  463. this.$refs.detail.init(id)
  464. })
  465. },
  466. // 变更通知人设置
  467. setNoticeChangeHandel () {
  468. this.noticeChangeVisible = true
  469. this.$nextTick(() => {
  470. this.$refs.noticeChangeSetting.init()
  471. })
  472. },
  473. // 对应图纸
  474. drawDetails (row) {
  475. this.drawVisible = true
  476. this.$nextTick(() => {
  477. this.$refs.drawDetail.init(row.proDrawings)
  478. })
  479. },
  480. // 对应工艺
  481. techDetails (id) {
  482. this.craftsVisible = true
  483. this.$nextTick(() => {
  484. this.$refs.craftsDetail.init(id)
  485. })
  486. },
  487. // 物料更改通知单
  488. changeDetails (row) {
  489. this.changeVisible = true
  490. this.$nextTick(() => {
  491. this.$refs.changeDetail.init(row.noticeChangeRecord.attachList)
  492. })
  493. },
  494. // 物料技术文件
  495. attachDetails (row) {
  496. this.attachVisible = true
  497. this.$nextTick(() => {
  498. this.$refs.attachDetail.init(row.attachList)
  499. })
  500. },
  501. // 物料配料清单附件
  502. attachDetails2 (row) {
  503. this.attachVisible = true
  504. this.$nextTick(() => {
  505. this.$refs.attachDetail.init(row.listingList)
  506. })
  507. },
  508. // 状态
  509. formatState (row) {
  510. if (!row.state) return ''
  511. let option = this.bomStateOption.find(t => t.value === row.state)
  512. if (option != null) {
  513. return option.label
  514. }
  515. return ''
  516. },
  517. formatReadState (row) {
  518. if (!row.writeState) return ''
  519. let option = this.writeStateOption.find(t => t.value === row.writeState)
  520. if (option != null) {
  521. return option.label
  522. }
  523. return ''
  524. },
  525. pauseHandle (id) {
  526. if (!id) return
  527. this.$confirm(`确定暂停?`, '提示', {
  528. confirmButtonText: '确定',
  529. cancelButtonText: '取消',
  530. type: 'warning'
  531. }).then(() => {
  532. this.$http({
  533. url: this.$http.adornUrl(`/biz-service/product/pause`),
  534. method: 'POST',
  535. data: {id: id}
  536. }).then(({data}) => {
  537. if (data && data.code === '200') {
  538. this.$message({
  539. message: '操作成功',
  540. type: 'success',
  541. duration: 1500,
  542. onClose: () => {
  543. this.getDataList()
  544. }
  545. })
  546. } else {
  547. this.$message.error(data.msg)
  548. }
  549. })
  550. }).catch(() => {})
  551. },
  552. regainHandle (id) {
  553. if (!id) return
  554. this.$confirm(`确定恢复?`, '提示', {
  555. confirmButtonText: '确定',
  556. cancelButtonText: '取消',
  557. type: 'warning'
  558. }).then(() => {
  559. this.$http({
  560. url: this.$http.adornUrl(`/biz-service/product/regain`),
  561. method: 'POST',
  562. data: {id: id}
  563. }).then(({data}) => {
  564. if (data && data.code === '200') {
  565. this.$message({
  566. message: '操作成功',
  567. type: 'success',
  568. duration: 1500,
  569. onClose: () => {
  570. this.getDataList()
  571. }
  572. })
  573. } else {
  574. this.$message.error(data.msg)
  575. }
  576. })
  577. }).catch(() => {})
  578. },
  579. readHandle (id) {
  580. if (!id) return
  581. this.$confirm(`确定只读?`, '提示', {
  582. confirmButtonText: '确定',
  583. cancelButtonText: '取消',
  584. type: 'warning'
  585. }).then(() => {
  586. this.$http({
  587. url: this.$http.adornUrl(`/biz-service/product/read`),
  588. method: 'POST',
  589. data: {id: id}
  590. }).then(({data}) => {
  591. if (data && data.code === '200') {
  592. this.$message({
  593. message: '操作成功',
  594. type: 'success',
  595. duration: 1500,
  596. onClose: () => {
  597. this.getDataList()
  598. }
  599. })
  600. } else {
  601. this.$message.error(data.msg)
  602. }
  603. })
  604. }).catch(() => {})
  605. },
  606. writeHandle (id) {
  607. if (!id) return
  608. this.$confirm(`确定读写?`, '提示', {
  609. confirmButtonText: '确定',
  610. cancelButtonText: '取消',
  611. type: 'warning'
  612. }).then(() => {
  613. this.$http({
  614. url: this.$http.adornUrl(`/biz-service/product/write`),
  615. method: 'POST',
  616. data: {id: id}
  617. }).then(({data}) => {
  618. if (data && data.code === '200') {
  619. this.$message({
  620. message: '操作成功',
  621. type: 'success',
  622. duration: 1500,
  623. onClose: () => {
  624. this.getDataList()
  625. }
  626. })
  627. } else {
  628. this.$message.error(data.msg)
  629. }
  630. })
  631. }).catch(() => {})
  632. },
  633. importFromExcel () {
  634. this.importVisible = true
  635. },
  636. handleUpload (file) {
  637. if (file == null) {
  638. this.$message.error('请上传清单文件')
  639. return
  640. }
  641. console.log(this.fileList)
  642. const formData = new FormData()
  643. formData.append('importFile', file.file)
  644. this.$http({
  645. url: this.$http.adornUrl(`/biz-service/product/importExcel`),
  646. method: 'POST',
  647. data: formData
  648. }).then(({data}) => {
  649. if (data && data.code === '200') {
  650. this.$message({
  651. message: '导入成功',
  652. type: 'success',
  653. duration: 1500,
  654. onClose: () => {
  655. this.importVisible = false
  656. }
  657. })
  658. } else {
  659. this.$message.error(data.msg)
  660. }
  661. })
  662. },
  663. // 上传
  664. submitUpload () {
  665. this.$refs.upload.submit()
  666. },
  667. // 移除
  668. handleRemove (file, fileList) {
  669. this.$emit('input', fileList)
  670. },
  671. templateDownload () {
  672. location.href = this.$http.adornUrl(`/biz-service/product/template/download?_token=${Vue.cookie.get('token')}`)
  673. }
  674. }
  675. }
  676. </script>
  677. <style scoped>
  678. </style>