index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. <template>
  2. <ele-modal title="新建领料单" :visible.sync="visible" :before-close="handleClose" :close-on-click-modal="false"
  3. :maxable="true"
  4. :close-on-press-escape="false" append-to-body width="80%">
  5. <el-form>
  6. <el-row :gutter="24">
  7. <el-col :span="6">
  8. <el-form-item label="领料单编号" prop="pickCode" label-width="90px">
  9. <el-input v-model="pickCode" disabled=""></el-input>
  10. </el-form-item>
  11. </el-col>
  12. <el-col :span="6">
  13. <el-form-item label="领料单名称" prop="pickName" label-width="90px">
  14. <el-input v-model="pickName" style="width: 260px;"></el-input>
  15. </el-form-item>
  16. </el-col>
  17. </el-row>
  18. </el-form>
  19. <div v-for="(item, idx) in workList" :key="idx">
  20. <el-form :ref="`formRef${idx}`" :model="{ pickList: item }" :rules="tableRules" size="mini" label-position="left">
  21. <div class="tableZ_box">
  22. <div class="row">
  23. <div class="col">
  24. <div class="name">生产工单号</div>
  25. <div class="content">{{ item.code }}</div>
  26. </div>
  27. <div class="col">
  28. <div class="name">产品编码</div>
  29. <div class="content">{{ item.productCode }}</div>
  30. </div>
  31. <div class="col">
  32. <div class="name">产品名称</div>
  33. <div class="content">{{ item.productName }}</div>
  34. </div>
  35. <div class="col">
  36. <div class="name">批次号</div>
  37. <div class="content">{{ item.batchNo }}</div>
  38. </div>
  39. <div class="col pd6" v-if="clientEnvironmentId!=21">
  40. <el-button type="primary" size="mini" @click="openPicking(item.id, item)">新增</el-button>
  41. </div>
  42. </div>
  43. </div>
  44. <div>
  45. <el-table :ref="`tableRef${idx}`" class="table_content" :max-height="300" :data="item.pickList"
  46. tooltip-effect="dark" style="width: 100%" stripe border>
  47. <el-table-column label="序号" type="index" width="60">
  48. <template slot-scope="{ row, $index }">
  49. {{ $index }}
  50. </template>
  51. </el-table-column>
  52. <el-table-column label="类型" prop="rootCategoryLevelId" width="80">
  53. <template slot-scope="{ row, $index }">
  54. <el-tag size="mini">{{ typeName[Number(row.rootCategoryLevelId)] }}</el-tag>
  55. </template>
  56. </el-table-column>
  57. <el-table-column label="编码" prop="assetCode">
  58. <template slot-scope="{ row, $index }">
  59. <span v-if="
  60. Object.prototype.hasOwnProperty.call(row, 'isBom') &&
  61. row.isBom == 1
  62. " style="color: #faad14">
  63. {{ row.categoryCode }}
  64. </span>
  65. <span>
  66. {{
  67. row.rootCategoryLevelId == 4 ? row.codeNumber : row.code
  68. }}</span>
  69. </template>
  70. </el-table-column>
  71. <el-table-column label="名称" prop="name">
  72. <template slot-scope="{ row, $index }">
  73. <span v-if="
  74. Object.prototype.hasOwnProperty.call(row, 'isBom') &&
  75. row.isBom == 1
  76. ">
  77. {{ row.categoryName }}
  78. </span>
  79. <span> {{ row.name }}</span>
  80. </template>
  81. </el-table-column>
  82. <el-table-column label="型号" prop="modelType"> </el-table-column>
  83. <el-table-column label="规格" prop="specification">
  84. </el-table-column>
  85. <el-table-column label="批次号" prop="batchNo"> </el-table-column>
  86. <el-table-column label="数量" prop="demandQuantity">
  87. <template slot-scope="{ row, $index }">
  88. <el-form-item>
  89. <el-input v-model="row.demandQuantity" @input="
  90. row.demandQuantity > row.availableCountBase
  91. ? (row.demandQuantity = row.availableCountBase)
  92. : row.demandQuantity
  93. " size="mini" style="width: 150px">
  94. <template slot="append">{{ row.measuringUnit }}</template>
  95. </el-input>
  96. </el-form-item>
  97. </template>
  98. </el-table-column>
  99. <el-table-column label="计量库存数量" prop="availableCountBase">
  100. <template slot-scope="{ row, $index }">
  101. {{ row.availableCountBase }} {{ row.measuringUnit }}
  102. </template>
  103. </el-table-column>
  104. <el-table-column label="领料仓库" prop="warehouseId">
  105. <template slot-scope="{ row, $index }">
  106. <div v-if="
  107. Object.prototype.hasOwnProperty.call(row, 'isBom') &&
  108. row.isBom == 1
  109. ">
  110. <el-select v-model="row.warehouseId" placeholder="请选择" filterable>
  111. <el-option v-for="item in row.warehouseList" :label="item.name" :value="item.id" :key="item.id">
  112. </el-option>
  113. </el-select>
  114. </div>
  115. <div v-else-if="clientEnvironmentId==21">
  116. <el-select v-model="row.warehouseId" placeholder="请选择" filterable>
  117. <el-option v-for="item in row.warehouseList" :label="item.name" :value="item.id" :key="item.id">
  118. </el-option>
  119. </el-select>
  120. </div>
  121. <div v-else>
  122. <el-select v-model="row.warehouseId" placeholder="请选择" filterable>
  123. <el-option v-for="item in row.warehouseLists" :label="item.warehouse_name"
  124. :value="item.warehouse_id" :key="item.warehouse_id">
  125. </el-option>
  126. </el-select>
  127. </div>
  128. </template>
  129. </el-table-column>
  130. <el-table-column label="操作" fixed="right" width="100px">
  131. <template slot-scope="{ $index, row }">
  132. <el-link type="danger" @click="removeItem(idx, $index)">删除</el-link>
  133. </template>
  134. </el-table-column>
  135. </el-table>
  136. </div>
  137. </el-form>
  138. </div>
  139. <template slot="footer">
  140. <el-button size="mini" @click="handleClose">取 消</el-button>
  141. <el-button size="mini" type="primary" @click="save()">确 定</el-button>
  142. </template>
  143. <pickingList isType="pick" ref="pickingListRef" @allSelection="allSelection"></pickingList>
  144. </ele-modal>
  145. </template>
  146. <script>
  147. import pickingList from './pickingList.vue';
  148. import { workorderList, getCode,getInventoryTotal,znworkorderList } from '@/api/produce/workOrder';
  149. import { typeName } from '../common.js';
  150. import { batchSave,znfindVoucherList } from '@/api/produce/picking';
  151. export default {
  152. components: {
  153. pickingList
  154. },
  155. props: {
  156. workListIds: {
  157. type: Array,
  158. default() {
  159. return [];
  160. }
  161. }
  162. },
  163. data() {
  164. return {
  165. visible: true,
  166. workList: [],
  167. rules: {},
  168. pickCode: null,
  169. pickName: null,
  170. typeName,
  171. tableRules: {}
  172. };
  173. },
  174. computed: {
  175. taskObj() {
  176. return this.$store.state.user.taskObj;
  177. },
  178. clientEnvironmentId() {
  179. return this.$store.state.user.info.clientEnvironmentId;
  180. }
  181. },
  182. watch: {},
  183. methods: {
  184. getList() {
  185. let param = {
  186. ids: this.workListIds,
  187. taskId: this.taskObj.id
  188. };
  189. console.log('1111122222',this.clientEnvironmentId)
  190. if(this.clientEnvironmentId==21){
  191. znworkorderList(param).then((res) => {
  192. let arr = res.map((e) => {
  193. e.bomDetailDTOS.map((d) => {
  194. e.warehouseId = d.warehouseList.length >0 ? d.warehouseList[0].id : ''
  195. })
  196. e.pickList = [...e.bomDetailDTOS];
  197. e.bomDetailDTOS = [];
  198. return e;
  199. });
  200. this.pickName = res[0].batchNo||'' + res[0].bomCategoryId||'';
  201. // arr.bomDetailDTOS.map(v=>{
  202. // this.getInventoryTotalFn(v.id)
  203. // })
  204. // getInventoryTotal
  205. // this.workList = arr;
  206. this.$set(this, 'workList', arr);
  207. this.getOrderCode();
  208. this.$forceUpdate();
  209. });
  210. }else{
  211. workorderList(param).then((res) => {
  212. let arr = res.map((e) => {
  213. e.bomDetailDTOS.map((d) => {
  214. e.warehouseId = d.warehouseList.length >0 ? d.warehouseList[0].id : ''
  215. })
  216. e.pickList = [...e.bomDetailDTOS];
  217. e.bomDetailDTOS = [];
  218. return e;
  219. });
  220. this.pickName = res[0].batchNo + res[0].bomCategoryId;
  221. // arr.bomDetailDTOS.map(v=>{
  222. // this.getInventoryTotalFn(v.id)
  223. // })
  224. // getInventoryTotal
  225. // this.workList = arr;
  226. this.$set(this, 'workList', arr);
  227. this.getOrderCode();
  228. this.$forceUpdate();
  229. });
  230. }
  231. },
  232. async getInventoryTotalFn(id) {
  233. return new Promise(async (solid, reject) => {
  234. const res = await getInventoryTotal(id);
  235. solid(res)
  236. })
  237. },
  238. async getOrderCode() {
  239. console.log(this.workListIds, '555555');
  240. this.pickCode = await getCode('pick_order_code');
  241. },
  242. removeItem(idx, index) {
  243. this.workList[idx].pickList.splice(index, 1);
  244. },
  245. handleClose() {
  246. this.$emit('close', false);
  247. },
  248. openPicking(id, item) {
  249. this.$refs.pickingListRef.open(id, item,'选择列表');
  250. },
  251. allSelection(id, list) {
  252. this.workList.forEach((e) => {
  253. if (e.id == id) {
  254. e.pickList = list;
  255. this.$forceUpdate();
  256. }
  257. });
  258. },
  259. save() {
  260. console.log(this.workList,'cvassasasag');
  261. if (this.workList.length > 0) {
  262. let bol;
  263. let _i;
  264. bol = this.workList.every((e, i) => {
  265. _i = i;
  266. return (
  267. Object.prototype.hasOwnProperty.call(e, 'pickList') &&
  268. e.pickList.length > 0
  269. );
  270. });
  271. if (!bol) {
  272. this.$message.warning(
  273. `生成工单${this.workList[_i].code}领料不能为空`
  274. );
  275. return false;
  276. }
  277. }
  278. if (this.workList.length > 0) {
  279. let name;
  280. let bol2;
  281. let _i;
  282. this.workList.forEach((e, i) => {
  283. _i = i;
  284. console.log(e.pickList);
  285. bol2 = e.pickList.every((y) => {
  286. name = y.name;
  287. return (
  288. Object.prototype.hasOwnProperty.call(y, 'demandQuantity') &&
  289. Number(y.demandQuantity) > 0
  290. );
  291. });
  292. });
  293. if (!bol2) {
  294. this.$message.warning(
  295. `${this.workList[_i].code}的${name}数量不能为空`
  296. );
  297. return false;
  298. }
  299. }
  300. let _arr = [];
  301. _arr = this.workList.map((m) => {
  302. m.instanceList = [];
  303. m.bomDetailDTOSList = [];
  304. m.pickList.forEach((e) => {
  305. if (
  306. Object.prototype.hasOwnProperty.call(e, 'isBom') &&
  307. e.isBom == 1
  308. ) {
  309. m.bomDetailDTOSList.push(e);
  310. } else {
  311. m.instanceList.push(e);
  312. }
  313. });
  314. m.workOrderId = m.id;
  315. delete m.id;
  316. return {
  317. ...m
  318. };
  319. });
  320. if(this.clientEnvironmentId==21){
  321. let param={
  322. workOrderId: this.workListIds[0],
  323. pickingCode: this.pickCode
  324. }
  325. znfindVoucherList(param).then((res) => {
  326. this.$message.success('领料成功');
  327. });
  328. }
  329. let param = {
  330. allPickList: _arr,
  331. pickName: this.pickName,
  332. pickCode: this.pickCode
  333. };
  334. batchSave(param).then((res) => {
  335. this.$message.success('领料成功');
  336. this.$emit('close', true);
  337. });
  338. }
  339. },
  340. created() {
  341. this.getList();
  342. }
  343. };
  344. </script>
  345. <style lang="scss" scoped>
  346. .table_content {
  347. margin-bottom: 10px;
  348. }
  349. .tableZ_box {
  350. border: 1px solid #e3e5e5;
  351. margin: 6px 0;
  352. &:last-child {
  353. border-bottom: none;
  354. }
  355. .row {
  356. width: 100%;
  357. display: flex;
  358. }
  359. .col {
  360. width: calc(100% / 5);
  361. display: flex;
  362. align-items: center;
  363. min-width: 200px;
  364. min-height: 32px;
  365. border-bottom: 1px solid #e3e5e5;
  366. border-right: 1px solid #e3e5e5;
  367. &:last-child {
  368. border-right: none;
  369. }
  370. .name {
  371. display: flex;
  372. align-items: center;
  373. padding: 4px;
  374. width: 80px;
  375. height: 100%;
  376. background-color: #d0e4d5;
  377. color: #000;
  378. }
  379. .content {
  380. padding: 4px 6px;
  381. color: #000;
  382. }
  383. }
  384. .pd6 {
  385. padding: 0 6px;
  386. }
  387. }
  388. </style>
  389. <style>
  390. :v-deep .el-form-item__error {
  391. bottom: -6px !important;
  392. }
  393. </style>