scheduling.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. <!-- 任务处理中心 -->
  2. <template>
  3. <div class="production">
  4. <template v-if="!detailsVisible && !outsourceVisible && !checkVisible && !preCheckVisible && !purchaseVisible && !printLabelVisible && !addOrUpdateVisible && !addOrUpdateOutsourceVisible">
  5. <el-header style="font-size: large;text-align: center">任务处理中心</el-header>
  6. <el-form>
  7. <el-form-item>
  8. <el-button v-if="isAuth('prod:production:purchase')" type="primary" @click="batchBuyHandle()" :disabled="batchIncomeBtnDisabled">批量转采购</el-button>
  9. <el-button v-if="isAuth('pur:commDetail:save')" type="primary" @click="batchOutsourceHandle()" :disabled="batchBtnDisabled">批量转委外</el-button>
  10. </el-form-item>
  11. </el-form>
  12. <el-table
  13. @selection-change="handleSelectionChange"
  14. :data="dataList"
  15. row-key="id"
  16. border
  17. :indent='20'
  18. lazy
  19. :load="loadingData"
  20. v-loading="dataListLoading"
  21. style="width: 100%;">
  22. <el-table-column
  23. type="selection"
  24. width="55">
  25. </el-table-column>
  26. <el-table-column
  27. label="序号"
  28. type="index"
  29. width="50"
  30. align="center">
  31. </el-table-column>
  32. <el-table-column
  33. prop="orderCode"
  34. header-align="center"
  35. align="center"
  36. min-width="200"
  37. :show-tooltip-when-overflow="true"
  38. label="任务单编码">
  39. </el-table-column>
  40. <el-table-column
  41. prop="mapNumber"
  42. header-align="center"
  43. align="center"
  44. min-width="120"
  45. :show-tooltip-when-overflow="true"
  46. label="图号">
  47. </el-table-column>
  48. <el-table-column
  49. prop="productName"
  50. header-align="center"
  51. align="center"
  52. min-width="160"
  53. :show-tooltip-when-overflow="true"
  54. label="物料名称">
  55. </el-table-column>
  56. <el-table-column
  57. prop="productSpec"
  58. header-align="center"
  59. align="center"
  60. min-width="160"
  61. :show-tooltip-when-overflow="true"
  62. label="规格">
  63. </el-table-column>
  64. <el-table-column
  65. prop="materials"
  66. header-align="center"
  67. align="center"
  68. min-width="160"
  69. :show-tooltip-when-overflow="true"
  70. label="材料">
  71. </el-table-column>
  72. <el-table-column
  73. prop="productNumber"
  74. header-align="center"
  75. align="center"
  76. min-width="120"
  77. :show-tooltip-when-overflow="true"
  78. label="生产编号">
  79. </el-table-column>
  80. <el-table-column
  81. header-align="center"
  82. align="center"
  83. label="对应工艺">
  84. <template slot-scope="scope">
  85. <el-button :disabled="!scope.row.techId" type="text" size="small" @click="techDetails(scope.row.techId)">查看</el-button>
  86. </template>
  87. </el-table-column>
  88. <el-table-column
  89. prop="cnt"
  90. header-align="center"
  91. align="center"
  92. min-width="100"
  93. label="数量">
  94. </el-table-column>
  95. <el-table-column
  96. prop="isAppraise"
  97. header-align="center"
  98. align="center"
  99. :formatter="formatAppraise"
  100. label="是否鉴定">
  101. </el-table-column>
  102. <el-table-column
  103. prop="isFirst"
  104. header-align="center"
  105. align="center"
  106. :formatter="formatFirst"
  107. label="是否首件">
  108. </el-table-column>
  109. <el-table-column
  110. prop="deliveryDate"
  111. header-align="center"
  112. align="center"
  113. min-width="160"
  114. label="交期时间">
  115. </el-table-column>
  116. <el-table-column
  117. prop="batchNumber"
  118. header-align="center"
  119. align="center"
  120. min-width="140"
  121. :show-tooltip-when-overflow="true"
  122. label="批次号">
  123. </el-table-column>
  124. <el-table-column
  125. prop="notes"
  126. header-align="center"
  127. align="center"
  128. width="180"
  129. :show-tooltip-when-overflow="true"
  130. label="备注">
  131. </el-table-column>
  132. <el-table-column
  133. prop="inventoryCnt"
  134. header-align="center"
  135. align="center"
  136. min-width="140"
  137. label="仓库核对数量">
  138. </el-table-column>
  139. <el-table-column
  140. prop="customerName"
  141. header-align="center"
  142. align="center"
  143. min-width="160"
  144. :show-tooltip-when-overflow="true"
  145. label="客户名称">
  146. </el-table-column>
  147. <el-table-column
  148. prop="contractNumber"
  149. header-align="center"
  150. align="center"
  151. min-width="140"
  152. :show-tooltip-when-overflow="true"
  153. label="合同编号">
  154. </el-table-column>
  155. <el-table-column
  156. fixed="right"
  157. prop="prodState"
  158. header-align="center"
  159. align="center"
  160. width="120"
  161. :formatter="formatState"
  162. label="当前状态">
  163. </el-table-column>
  164. <el-table-column
  165. fixed="right"
  166. prop="state"
  167. header-align="center"
  168. align="center"
  169. :formatter="formatState2"
  170. label="处理状态">
  171. </el-table-column>
  172. <el-table-column
  173. fixed="right"
  174. header-align="center"
  175. align="center"
  176. width="240"
  177. label="操作">
  178. <template slot-scope="scope">
  179. <el-button v-if="isAuth('prod:production:updateCheck') && Number(scope.row.prodState) === 0" type="text" size="small" @click="check(scope.row)">核料</el-button>
  180. <el-button v-if="isAuth('prod:production:purchase') && Number(scope.row.prodState) === 2" type="text" size="small" @click="purchaseHandle(scope.row)">转采购</el-button>
  181. <el-button v-if="isAuth('pur:commDetail:save') && Number(scope.row.prodState) === 2" type="text" size="small" @click="outsourceHandle(scope.row)">转委外</el-button>
  182. <!-- <el-button v-if="isAuth('prod:production:examine') && Number(scope.row.prodState) === 1" type="text" size="small" @click="preCheck(scope.row.id)">试制前检查</el-button>-->
  183. <el-button v-if="isAuth('prod:production:plan') && Number(scope.row.prodState) === 2" type="text" size="small" @click="detail(scope.row.id, true)" v-reClick>排产</el-button>
  184. <!-- <el-button v-if="isAuth('pur:commDetail:save') && Number(scope.row.outsourcing) === 0" type="text" size="small" @click="outsourceHandle(scope.row.id)">委外生产</el-button>-->
  185. <el-button type="text" size="small" @click="printLabel(scope.row)">打印标签 + {{scope.row.printCnt}}</el-button>
  186. </template>
  187. </el-table-column>
  188. </el-table>
  189. <el-pagination
  190. @size-change="sizeChangeHandle"
  191. @current-change="currentChangeHandle"
  192. :current-page="pageIndex"
  193. :page-sizes="[10, 20, 50, 100]"
  194. :page-size="pageSize"
  195. :total="totalPage"
  196. layout="total, sizes, prev, pager, next, jumper">
  197. </el-pagination>
  198. </template>
  199. <!-- 弹窗, 新增 / 修改 -->
  200. <detail v-if="detailsVisible" ref="details" @close="closeDialogEvent" @refreshDataList="getDataList" @onChose="onChose"/>
  201. <!-- 委外 -->
  202. <scheduling-commission v-if="outsourceVisible" ref="outsource" @refreshDataList="getDataList" @onChose="onChose"/>
  203. <!-- 采购 -->
  204. <scheduling-purchase v-if="purchaseVisible" ref="purchase" @refreshDataList="getDataList" @onChose="onChose"/>
  205. <!-- 核料 -->
  206. <scheduling-check v-if="checkVisible" ref="check" @refreshDataList="getDataList" @onChose="onChose"/>
  207. <!-- 试制前检查 -->
  208. <scheduling-pre-check v-if="preCheckVisible" ref="preCheck" @refreshDataList="getDataList" @onChose="onChose"/>
  209. <!-- 对应工艺 -->
  210. <crafts-detail v-if="craftsVisible" ref="craftsDetail"/>
  211. <!-- 打印标签 -->
  212. <print-label v-if="printLabelVisible" ref="printLabel" @onChose="onChose" @addOne="addOneClick"/>
  213. <!-- 弹窗, 新增 / 修改 -->
  214. <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" :options-type="optionsType" @refreshDataList="getDataList" @onChose="onChose"></add-or-update>
  215. <!-- 委外 -->
  216. <outsource-add-or-update v-if="addOrUpdateOutsourceVisible" ref="addOrUpdateOutsource" @refreshDataList="getDataList" @onChose="onChose"></outsource-add-or-update>
  217. </div>
  218. </template>
  219. <script>
  220. import Detail from './scheduling-details'
  221. import OutsourceAddOrUpdate from '@/views/modules/sale/outsource-add-or-update'
  222. import { getSchedulingList, getChildren } from '@/api/production'
  223. import SchedulingCheck from '@/views/modules/production/scheduling-check'
  224. import SchedulingPreCheck from '@/views/modules/production/scheduling-pre-check'
  225. import PurchaseAddOrUpdate from '@/views/modules/sale/purchase-add-or-update'
  226. import SchedulingPurchase from '@/views/modules/production/scheduling-purchase'
  227. import SchedulingCommission from '@/views/modules/production/scheduling-commission'
  228. import CraftsDetail from '@/views/modules/tech/crafts-detail-dialog'
  229. import {downloadUrl} from '@/api/file'
  230. import PrintLabel from '@/views/modules/production/components/print-label.vue'
  231. import AddOrUpdate from '@/views/modules/sale/purchase-add-or-update'
  232. import { getDictList } from '@/api/dict'
  233. export default {
  234. name: 'scheduling',
  235. components: {
  236. PrintLabel,
  237. CraftsDetail,
  238. SchedulingCommission,
  239. SchedulingPurchase,
  240. PurchaseAddOrUpdate,
  241. SchedulingPreCheck,
  242. SchedulingCheck,
  243. Detail,
  244. AddOrUpdate,
  245. OutsourceAddOrUpdate
  246. },
  247. data () {
  248. return {
  249. detailsVisible: false,
  250. outsourceVisible: false,
  251. checkVisible: false,
  252. preCheckVisible: false,
  253. purchaseVisible: false,
  254. craftsVisible: false,
  255. printLabelVisible: false,
  256. addOrUpdateVisible: false,
  257. addOrUpdateOutsourceVisible: false,
  258. dataForm: {},
  259. dataList: [],
  260. pageIndex: 1,
  261. pageSize: 10,
  262. totalPage: 0,
  263. dataListLoading: false,
  264. dataListSelections: [],
  265. // 当前状态
  266. optionsProdState: [
  267. {
  268. code: '0',
  269. value: '待核料'
  270. },
  271. {
  272. code: '1',
  273. value: '待试制前检查'
  274. },
  275. {
  276. code: '2',
  277. value: '待排产'
  278. },
  279. {
  280. code: '3',
  281. value: '生产中'
  282. },
  283. {
  284. code: '4',
  285. value: '生产完成'
  286. },
  287. {
  288. code: '5',
  289. value: '不合格完成'
  290. }
  291. ],
  292. // 处理状态
  293. optionsState: [
  294. {
  295. code: '2',
  296. value: '待处理'
  297. },
  298. {
  299. code: '3',
  300. value: '采购'
  301. },
  302. {
  303. code: '4',
  304. value: '委外'
  305. },
  306. {
  307. code: '5',
  308. value: '生产'
  309. }
  310. ],
  311. multipleSelection: [],
  312. selectedRows:[],
  313. batchIncomeBtnDisabled: false,
  314. batchBtnDisabled: false,
  315. optionsType: [],
  316. }
  317. },
  318. created () {
  319. this.getTypeList()
  320. this.getDataList()
  321. },
  322. methods: {
  323. onChose () {
  324. this.detailsVisible = false
  325. this.outsourceVisible = false
  326. this.checkVisible = false
  327. this.preCheckVisible = false
  328. this.purchaseVisible = false
  329. this.craftsVisible = false
  330. this.printLabelVisible = false
  331. this.selectedRows = []
  332. this.batchIncomeBtnDisabled = false
  333. this.batchBtnDisabled = false
  334. this.addOrUpdateVisible = false
  335. this.addOrUpdateOutsourceVisible = false
  336. },
  337. // 获取采购类别字典
  338. getTypeList () {
  339. getDictList({type: 'purchase_type'}).then(({data}) => {
  340. if (data) {
  341. this.optionsType = data
  342. }
  343. })
  344. },
  345. // 查询
  346. queryPage () {
  347. this.pageIndex = 1
  348. this.getDataList()
  349. },
  350. // 获取数据列表
  351. getDataList () {
  352. this.selectedRows = []
  353. this.batchIncomeBtnDisabled = false
  354. this.batchBtnDisabled = false
  355. this.dataListLoading = true
  356. let params = {
  357. 'current': this.pageIndex,
  358. 'size': this.pageSize
  359. }
  360. getSchedulingList(params).then(({data}) => {
  361. if (data && data.code === '200') {
  362. this.dataList = data.data.records
  363. // 设置已打印标签数量的初始值
  364. if (this.dataList) {
  365. this.dataList.forEach((item) => {
  366. item.printCnt = 0
  367. })
  368. }
  369. this.totalPage = Number(data.data.total)
  370. } else {
  371. this.dataList = []
  372. this.totalPage = 0
  373. }
  374. this.dataListLoading = false
  375. })
  376. },
  377. // 每页数
  378. sizeChangeHandle (val) {
  379. this.pageSize = val
  380. this.pageIndex = 1
  381. this.getDataList()
  382. },
  383. // 当前页
  384. currentChangeHandle (val) {
  385. this.pageIndex = val
  386. this.getDataList()
  387. },
  388. // 多选
  389. selectionChangeHandle (val) {
  390. this.dataListSelections = val
  391. },
  392. // 新增 / 修改
  393. detail (id, disable) {
  394. this.detailsVisible = true
  395. this.$nextTick(() => {
  396. this.$refs.details.init(id, disable)
  397. })
  398. },
  399. // 转换属性:是否
  400. formatAppraise (row) {
  401. if (!row.isAppraise) return ''
  402. return row.isAppraise === '1' ? '否' : '是'
  403. },
  404. // 转换属性:是否
  405. formatFirst (row) {
  406. if (!row.isFirst) return ''
  407. return row.isFirst === '1' ? '否' : '是'
  408. },
  409. // 转换属性“当前状态”
  410. formatState (row) {
  411. if (!row.prodState) return ''
  412. const item1 = this.optionsProdState.find((item) => item.code === row.prodState.toString())
  413. return item1 ? item1.value : ''
  414. },
  415. // 转换属性“处理状态”
  416. formatState2 (row) {
  417. if (!row.state) {
  418. return ''
  419. }
  420. const item1 = this.optionsState.find((item) => item.code === row.state.toString())
  421. return item1 ? item1.value : ''
  422. },
  423. closeDialogEvent () {
  424. this.detailsVisible = false
  425. },
  426. // 委外生产
  427. outsourceHandle (row) {
  428. this.outsourceVisible = true
  429. this.$nextTick(() => {
  430. this.$refs.outsource.init(row)
  431. })
  432. },
  433. // 采购
  434. purchaseHandle (row) {
  435. this.purchaseVisible = true
  436. this.$nextTick(() => {
  437. this.$refs.purchase.init(row)
  438. })
  439. },
  440. // 核料
  441. check (row) {
  442. this.checkVisible = true
  443. this.$nextTick(() => {
  444. this.$refs.check.init(row)
  445. })
  446. },
  447. // 核料
  448. preCheck (id) {
  449. this.preCheckVisible = true
  450. this.$nextTick(() => {
  451. this.$refs.preCheck.init(id)
  452. })
  453. },
  454. // 标签打印
  455. printLabel (row) {
  456. this.printLabelVisible = true
  457. this.$nextTick(() => {
  458. this.$refs.printLabel.init(row)
  459. })
  460. },
  461. // 对应工艺
  462. techDetails (id) {
  463. this.craftsVisible = true
  464. this.$nextTick(() => {
  465. this.$refs.craftsDetail.init(id)
  466. })
  467. },
  468. loadingData (row, treeNode, resolve) {
  469. getChildren(row.id).then(({data}) => {
  470. if (data && data.code === '200') {
  471. data.data.forEach(item => {
  472. if (item.attachList2 && item.attachList2.length > 0) {
  473. item.simplePic = downloadUrl + item.attachList2[0].url
  474. } else {
  475. item.simplePic = ''
  476. }
  477. })
  478. resolve(data.data)
  479. } else {
  480. this.$message.error(data.msg)
  481. }
  482. })
  483. },
  484. addOneClick (row) {
  485. // this.dataList 中匹配 row.id,找到对应的数据
  486. this.dataList.forEach((item) => {
  487. if (item.id === row.id) {
  488. if (!item.printCnt) {
  489. item.printCnt = 0
  490. }
  491. item.printCnt += 1
  492. }
  493. })
  494. },
  495. //监听批量选择的行
  496. handleSelectionChange(rows){
  497. this.selectedRows = rows
  498. //控制批量操作按钮
  499. this.batchIncomeBtnDisabled = false
  500. this.batchBtnDisabled = false
  501. for(let index=0;index<this.selectedRows.length;index++){
  502. let item = this.selectedRows[index]
  503. if(Number(item.prodState) === 2){
  504. } else {
  505. this.batchIncomeBtnDisabled = true
  506. }
  507. if(Number(item.prodState) === 2){
  508. } else {
  509. this.batchBtnDisabled = true
  510. }
  511. }
  512. },
  513. //批量转采购
  514. batchBuyHandle(){
  515. if(this.selectedRows.length == 0){
  516. this.$message.error("请先勾选数据")
  517. return
  518. }
  519. let list = []
  520. this.selectedRows.forEach(item => {
  521. list.push({
  522. detailId:Math.round(Math.random() * 1000000),
  523. materialName: item.materialName,
  524. specification:item.productSpec,
  525. purchaseType: '',
  526. cnt:item.cnt,
  527. unitName:'',
  528. deadline:'',
  529. batchNumber:item.batchNumber,
  530. notes:''
  531. })
  532. })
  533. this.addOrUpdateVisible = true
  534. this.$nextTick(() => {
  535. this.$refs.addOrUpdate.init(0, null, null, list)
  536. })
  537. },
  538. //批量转委外
  539. batchOutsourceHandle(){
  540. if(this.selectedRows.length == 0){
  541. this.$message.error("请先勾选数据")
  542. return
  543. }
  544. let list = []
  545. this.selectedRows.forEach(item => {
  546. list.push({
  547. detailId:Math.round(Math.random() * 1000000),
  548. productName: item.productName,
  549. productNumber:item.productNumber,
  550. productSpec: item.productSpec,
  551. cnt:item.cnt,
  552. unitName:'',
  553. deadline:'',
  554. batchNumber:item.batchNumber,
  555. arrivedTime:'',
  556. qualifiedCnt:'',
  557. price:'',
  558. taxPrice:'',
  559. taxAmount:'',
  560. taxRateVal:'',
  561. specificationExplian:'',
  562. notes:''
  563. })
  564. })
  565. this.addOrUpdateOutsourceVisible = true
  566. this.$nextTick(() => {
  567. this.$refs.addOrUpdateOutsource.init(null,null,null,list)
  568. })
  569. }
  570. }
  571. }
  572. </script>
  573. <style scoped>
  574. </style>