outsourceList.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. <template>
  2. <!-- 委外下一步 -->
  3. <div class="card">
  4. <div class="c_header_title">
  5. <div class="c_title">委外记录</div>
  6. </div>
  7. <div class="card_box">
  8. <el-descriptions>
  9. <el-descriptions-item label="委外名称">{{ outObj.name }}</el-descriptions-item>
  10. <el-descriptions-item label="委外类型">{{ outObj.type == 4 ? '带料委外' : '无料委外' }}</el-descriptions-item>
  11. <!-- <el-descriptions-item label="直接入库">{{ outObj.isInWarehouse == 1 ? '是' : '否' }}</el-descriptions-item> -->
  12. <el-descriptions-item label="直接入库">{{ '是' }}</el-descriptions-item>
  13. </el-descriptions>
  14. </div>
  15. <el-tabs v-model="activeName">
  16. <el-tab-pane label="物品清单" name="0">
  17. <div class="materialList">
  18. <div class="u-reset" style="display: flex;" v-if="clientEnvironmentId != 2">
  19. <el-checkbox color="#fff" v-model="checkedAll" :checked="seletedAll" @change="_seletedAll">全选
  20. </el-checkbox>
  21. <div class="gxList">勾选:<span style="color: #157A2C">{{ checkListLen || 0 }}个</span></div>
  22. </div>
  23. <!-- -->
  24. <!-- <el-checkbox-group v-model="checkList"> -->
  25. <div v-for="(item, index) in pickOutInList" :key="index">
  26. <div class="listBox rx-bs">
  27. <div class="listBox-sel">
  28. <el-checkbox v-model="item.checked" color="#fff"
  29. @change="e => selectVal(e, item, index)"
  30. v-if='(item.rootCategoryLevelId != 11 || (item.rootCategoryLevelId == 11 && item.status != 1)) && clientEnvironmentId != 2'
  31. >
  32. </el-checkbox>
  33. </div>
  34. <div class="listBox-con">
  35. <div class="listBox-top rx-bc">
  36. <div> {{ item.name }}</div>
  37. <div class="code">
  38. {{ item.rootCategoryLevelId == 4 ? item.codeNumber : item.code }}
  39. </div>
  40. </div>
  41. <div class="listBox-bottom rx">
  42. <div v-for="(itm, index) in tableH(item.rootCategoryLevelId)" :key="index"
  43. class="items" v-if="!itm.formatter">
  44. <span>{{ itm.label }}</span>{{ item[itm.prop] }}
  45. </div>
  46. <div class="items"
  47. v-if='(item.rootCategoryLevelId == 1 && item.isConsumable == 1) && item.rootCategoryLevelId != 11 && item.rootCategoryLevelId != 4'>
  48. <span>可用库存:</span>{{ item.availableCountBase }} {{ item.unit }}
  49. </div>
  50. <div class="items"
  51. v-if='([1, 2, 9, 23].includes(Number(item.rootCategoryLevelId)) && item.isConsumable == 0)'>
  52. <span>刻码:</span>{{ item.extInfo.engrave }}
  53. </div>
  54. <div class="items"
  55. v-if='([1, 2, 9, 23].includes(Number(item.rootCategoryLevelId)) && item.isConsumable == 0)'>
  56. <span>物料代号:</span>{{ item.extInfo.materielCode }}
  57. </div>
  58. <div class="items"
  59. v-if='([1, 2, 9, 23].includes(Number(item.rootCategoryLevelId)) && item.isConsumable == 0)'>
  60. <span>客户代号:</span>{{ item.extInfo.clientCode }}
  61. </div>
  62. <div class="items" style="width: 15%;"
  63. v-if='([1, 2, 9, 23].includes(Number(item.rootCategoryLevelId)) && item.isConsumable == 0)'>
  64. <span>重量:</span>{{ item.extInfo.newWeight }} {{ item.extInfo.weightUnit }}
  65. </div>
  66. <div class="items" style="width: 15%;"
  67. v-if='([1, 2, 9, 23].includes(Number(item.rootCategoryLevelId)) && item.isConsumable == 1)'>
  68. <span>数量:</span>{{ item.feedQuantity }}
  69. </div>
  70. <div class="items" style="width: 15%;"
  71. v-if='([1, 2, 9, 23].includes(Number(item.rootCategoryLevelId)) && item.isConsumable == 1)'>
  72. <span>重量:</span>{{ item.weight || 0 }} {{ item.weightUnit }}
  73. </div>
  74. <div class="items"
  75. v-if='([1, 2, 9, 23].includes(Number(item.rootCategoryLevelId)) && item.isConsumable == 1)'>
  76. <span>规格:</span> {{ item.specification }}
  77. </div>
  78. <div class="items"
  79. v-if='([1, 2, 9, 23].includes(Number(item.rootCategoryLevelId)) && item.isConsumable == 1)'>
  80. <span>型号:</span> {{ item.modelType }}
  81. </div>
  82. </div>
  83. </div>
  84. </div>
  85. </div>
  86. <!-- </el-checkbox-group> -->
  87. </div>
  88. </el-tab-pane>
  89. <el-tab-pane label="带料清单" name="1">
  90. <div class="materialList">
  91. <div class="u-reset">
  92. <el-button type="primary" size="small" class="u-reset-button" @click="openPicking(2)">
  93. 添加
  94. </el-button>
  95. </div>
  96. <div v-for="(item, index) in bomMaterialList" :key="index">
  97. <label class="listBox rx-bs">
  98. <div class="listBox-con">
  99. <div class="listBox-bottom rx">
  100. <div class="items">
  101. <span>序号</span>{{ index + 1 }}
  102. </div>
  103. <div class="items">
  104. <span>名称</span>{{ item.name }}
  105. </div>
  106. <div class="items">
  107. <span>编码</span>{{ item.code }}
  108. </div>
  109. <div v-for="(itm, index) in tableH(item.rootCategoryLevelId)" :key="index"
  110. class="items" v-if="!itm.formatter">
  111. <span>{{ itm.label }}</span>{{ item[itm.prop] }}
  112. </div>
  113. <div class="items" v-if="item.isDemandQuantity && clientEnvironmentId != 2"
  114. style="width: 15%;">
  115. <span>数量</span>{{ checkListLen == 0 ? item.demandQuantity : item.count * (
  116. checkListLen || 1) }}
  117. </div>
  118. <div class="items content_num"
  119. v-if="!item.isDemandQuantity && clientEnvironmentId != 2" style="width: 15%;">
  120. <span>数量</span> <input style="width: 8px !important"
  121. v-model="item.demandQuantity"></input>
  122. </div>
  123. <div class="items" v-if="item.isDemandQuantity && clientEnvironmentId == 2"
  124. style="width: 15%;">
  125. <span>数量</span>{{ item.count * (outObj.formedNumLast || 1) }}
  126. </div>
  127. <div class="items content_num"
  128. v-if="!item.isDemandQuantity && clientEnvironmentId == 2" style="width: 15%;">
  129. <span>数量</span> <input style="width:8rpx !important"
  130. v-model="item.demandQuantity"></input>
  131. </div>
  132. </div>
  133. </div>
  134. </label>
  135. </div>
  136. </div>
  137. </el-tab-pane>
  138. <el-tab-pane label="产出清单" name="2">
  139. <div class="materialList">
  140. <div class="u-reset">
  141. <el-button type="primary" size="small" class="u-reset-button" @click="openPicking(3)">
  142. 添加
  143. </el-button>
  144. </div>
  145. <div v-for="(item, index) in standardOutputList" :key="index">
  146. <label class="listBox rx-bs">
  147. <div class="listBox-con">
  148. <div class="listBox-bottom rx">
  149. <div class="items" style="width: 15%;">
  150. <span>序号</span>{{ index + 1 }}
  151. </div>
  152. <div class="items">
  153. <span>名称</span>{{ item.name }}
  154. </div>
  155. <div class="items">
  156. <span>编码</span>{{ item.code }}
  157. </div>
  158. <div v-for="(itm, index) in tableH(item.rootCategoryLevelId)" :key="index"
  159. class="items" v-if="!itm.formatter">
  160. <span>{{ itm.label }}</span>{{ item[itm.prop] }}
  161. </div>
  162. <div class="items content_num">
  163. <span>数量</span> <input style="width: 8rpx !important"
  164. v-model="item.demandQuantity"></input>
  165. </div>
  166. </div>
  167. </div>
  168. </label>
  169. </div>
  170. </div>
  171. </el-tab-pane>
  172. </el-tabs>
  173. <div class="operate_box rx-bc">
  174. <el-button size="small" class="u-reset-button" @click="close">
  175. 取消
  176. </el-button>
  177. <el-button type="primary" size="small" class="u-reset-button" @click="handOK(0)">
  178. 提交
  179. </el-button>
  180. <el-button type="primary" size="small" class="u-reset-button" @click="handOK(1)">
  181. 提交并发布
  182. </el-button>
  183. </div>
  184. <pickingList ref="pickingListRef" isType="weiwai" @allSelection="allSelection"></pickingList>
  185. </div>
  186. </template>
  187. <script>
  188. import {
  189. // checkOutsourceMaterial,
  190. applyoutsourceSave,
  191. // getWarehouseList
  192. } from '@/api/produce/index.js'
  193. import {
  194. tableHeader
  195. } from '@/utils/dict/common.js'
  196. // import {
  197. // EventBus
  198. // } from '@/utils/eventBus.js'
  199. import pickingList from './pickingList.vue'
  200. export default {
  201. components: { pickingList },
  202. data() {
  203. return {
  204. checkListLen: 0,
  205. checkedAll:true,
  206. checkList: [],
  207. mode: 'center',
  208. show: false,
  209. topHight: 20 || 20,
  210. activeName: "0",
  211. outObj: {
  212. name: '111',
  213. type: 4,
  214. isInWarehouse: 1
  215. },
  216. tabList: [{
  217. name: '物品清单'
  218. },
  219. {
  220. name: '带料清单'
  221. },
  222. {
  223. name: '产出清单'
  224. }
  225. ],
  226. actTab: '物品清单',
  227. datapickOutInList: [],
  228. bomMaterialList: [],
  229. pickOutInList: [],
  230. materialList: [],
  231. standardOutputList: [],
  232. isFirstTask: null,
  233. // clientEnvironmentId: uni.getStorageSync("userInfo") && uni.getStorageSync("userInfo")
  234. // .clientEnvironmentId, // *1 主环境-601环境 2 soll-索尔环境 3 tg-碳谷环境
  235. seletedAll: false, //全选状态
  236. checkListLen: 0,
  237. warehouseList: []
  238. }
  239. },
  240. created() {
  241. // EventBus.$on('outEvent', this.handleEvent);
  242. // this.outsourceMaterialFn()
  243. },
  244. computed: {
  245. clientEnvironmentId() {
  246. return this.$store.state.user.info.clientEnvironmentId;
  247. }
  248. },
  249. props: {
  250. outsourceFormVal: {
  251. type: Object,
  252. default: () => { }
  253. },
  254. },
  255. watch: {
  256. outsourceFormVal: {
  257. handler(val) {
  258. console.log(val, 'outsourceFormVal');
  259. this.outsourceMaterialFn(val);
  260. this.outObj = val;
  261. },
  262. deep: true,
  263. immediate: true
  264. }
  265. },
  266. methods: {
  267. // open(obj) {
  268. // // this.outObj = obj;
  269. // this.actTab = '物品清单';
  270. // // this.outsourceMaterialFn()
  271. // // this.getWarehouseFn()
  272. // },
  273. allSelection(e, item) {
  274. if (e == 2) {
  275. if (item.length) {
  276. item.map(v => {
  277. this.bomMaterialList.push(v)
  278. })
  279. }
  280. ;
  281. console.log(this.bomMaterialList);
  282. } else if (e == 3) {
  283. if (item.length) {
  284. this.standardOutputList = item;
  285. }
  286. }
  287. },
  288. openPicking(id) {
  289. this.$refs.pickingListRef.open(id);
  290. },
  291. outsourceMaterialFn(res) {
  292. let _arr = []
  293. _arr = [...res.pickOutInList, ...res.materialList]
  294. this.pickOutInList = _arr.reduce((acc, item) => {
  295. const existingItem = acc.find(existing => existing.id === item.id);
  296. if (!existingItem) {
  297. acc.push(item);
  298. }
  299. return acc;
  300. }, []);
  301. this.bomMaterialList = res.bomMaterialList.map((m) => {
  302. return {
  303. ...m,
  304. isDemandQuantity: true
  305. }
  306. })
  307. this.pickOutInList.map(v => {
  308. v.checked = true;
  309. })
  310. this.checkListLen = this.pickOutInList.length;
  311. this.standardOutputList = res.standardOutputList
  312. // let param = {
  313. // taskId: this.outObj.taskId,
  314. // taskIds: this.outObj.taskIds,
  315. // workOrderId: this.outObj.workOrderId
  316. // }
  317. // checkOutsourceMaterial(param).then(res => {
  318. // let _arr = []
  319. // _arr = [...res.pickOutInList, ...res.materialList]
  320. // this.pickOutInList = _arr.reduce((acc, item) => {
  321. // const existingItem = acc.find(existing => existing.id === item.id);
  322. // if (!existingItem) {
  323. // acc.push(item);
  324. // }
  325. // return acc;
  326. // }, []);
  327. // this.bomMaterialList = res.bomMaterialList.map((m) => {
  328. // return {
  329. // ...m,
  330. // isDemandQuantity: true
  331. // }
  332. // })
  333. // this.standardOutputList = res.standardOutputList
  334. // this.$forceUpdate()
  335. // })
  336. },
  337. // 仓库
  338. getWarehouseFn() {
  339. getWarehouseList().then(res => {
  340. this.warehouseList = res
  341. })
  342. },
  343. handTab(item) {
  344. this.actTab = item.name
  345. },
  346. //关闭弹窗
  347. close() {
  348. this.$emit('closeForm')
  349. },
  350. handleEvent({
  351. message
  352. }) {
  353. if (message.pid == 3) {
  354. this.standardOutputList = message.memoList
  355. } else {
  356. if (message.pid == 2) {
  357. this.bomMaterialList = message.memoList
  358. }
  359. }
  360. },
  361. tableH(type) {
  362. return tableHeader(type)
  363. },
  364. //勾选
  365. selectVal(e, val, index) {
  366. this.$forceUpdate()
  367. this.pickOutInList[index] = val
  368. this.$set(this, 'pickOutInList', this.pickOutInList)
  369. this.checkListLen = this.pickOutInList.filter(f => f.checked == true).length;
  370. },
  371. _seletedAll() {
  372. console.log(this.seletedAll,this.pickOutInList,'this.seletedAll');
  373. // this.seletedAll true 是全选
  374. if (!this.seletedAll) {
  375. // 非全选
  376. this.seletedAll = true;
  377. this.checkListLen = 0;
  378. this.pickOutInList.map(item => {
  379. item.checked =false;
  380. })
  381. this.$set(this, 'pickOutInList', this.pickOutInList)
  382. } else {
  383. this.seletedAll = false;
  384. this.pickOutInList.map(item => {
  385. item.checked =true;
  386. })
  387. this.$set(this, 'pickOutInList', this.pickOutInList)
  388. }
  389. this.checkListLen = this.pickOutInList.filter(f => f.checked == true).length
  390. },
  391. scrolltolower() { },
  392. addPicking(id) {
  393. const storageKey = Date.now() + "";
  394. let arr = null
  395. if (id == 3) {
  396. arr = [{
  397. standardOutputList: this.standardOutputList,
  398. }]
  399. } else {
  400. arr = [{
  401. bomMaterialList: this.bomMaterialList,
  402. }]
  403. }
  404. // uni.setStorageSync(storageKey, arr);
  405. // uni.navigateTo({
  406. // url: `/pages/pda/workOrder/search/index?id=${id}&storageKey=${storageKey}&isType=zdy&taskId=${this.outObj.taskId}&classIds=[1,23,9]`
  407. // })
  408. },
  409. handOK(isRelease) {
  410. // isRelease? 0 提交 2提交并发布
  411. if (this.checkListLen > 0 && !this.outObj.warehouseId) {
  412. return this.$message({
  413. message: "请选择仓库",
  414. type: "warning"
  415. })
  416. }
  417. // 环境判断
  418. let _pickOutInList = []
  419. if (this.clientEnvironmentId == 2) {
  420. _pickOutInList = this.pickOutInList
  421. } else {
  422. _pickOutInList = this.pickOutInList.filter(f => f.checked == true)
  423. }
  424. let param = {
  425. ...this.outObj,
  426. isRelease: isRelease,
  427. bomMaterialList: this.bomMaterialList,
  428. pickOutInList: _pickOutInList,
  429. materialList: this.materialList,
  430. standardOutputList: this.standardOutputList,
  431. }
  432. applyoutsourceSave(param).then(res => {
  433. return this.$message({
  434. message: "提交成功",
  435. type: "scuccess"
  436. })
  437. this.checkListLen = 0
  438. })
  439. },
  440. }
  441. }
  442. </script>
  443. <style lang="scss" scoped>
  444. .c_header_title {
  445. display: flex;
  446. align-items: center;
  447. margin-bottom: 0;
  448. height: 58px;
  449. margin-bottom: 10px;
  450. box-sizing: border-box;
  451. border-bottom: 1px solid var(--border-color-lighter);
  452. }
  453. .operate_box {
  454. padding: 15px;
  455. box-shadow: 0px -2px 15px 0px rgba(0, 0, 0, 0.1);
  456. }
  457. .c_title {
  458. color: #157a2c;
  459. font-size: 16px;
  460. font-weight: bold;
  461. }
  462. .materialList {
  463. height: 55vh;
  464. overflow-y: auto;
  465. }
  466. .card {
  467. width: 100%;
  468. padding: 0 20px;
  469. }
  470. .u-reset {
  471. width: 100%;
  472. padding: 5px;
  473. text-align: right;
  474. }
  475. .listBox-con {
  476. width: 100%;
  477. }
  478. .gxList{
  479. margin-left: 10px;
  480. }
  481. .listBox-sel {
  482. margin: 0 10px
  483. }
  484. .listBox-top {
  485. display: flex;
  486. padding: 15px;
  487. font-size: 14px;
  488. font-weight: bold;
  489. border-bottom: 1px solid #ddd;
  490. }
  491. .listBox-bottom {
  492. display: flex;
  493. width: 100%;
  494. flex-wrap: wrap;
  495. margin-bottom: 0;
  496. }
  497. .listBox {
  498. display: flex;
  499. align-items: center;
  500. border: 1px solid #ddd;
  501. margin-bottom: 20px;
  502. }
  503. .items {
  504. font-size: 12px;
  505. width: 28%;
  506. display: flex;
  507. align-items: center;
  508. // border: 1px solid #ddd;
  509. // border-bottom: 1px solid #ddd;
  510. // border-right: 0;
  511. span {
  512. display: block;
  513. padding: 10px;
  514. margin-right: 5px;
  515. color: #157a2c;
  516. background-color: #f7f9fa;
  517. }
  518. }
  519. </style>