plan-submit.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. <template>
  2. <el-dialog
  3. :visible.sync="visible"
  4. title="计划提交"
  5. width="60vw"
  6. append-to-body
  7. >
  8. <div class="main_container">
  9. <el-descriptions
  10. title=""
  11. :column="3"
  12. size="medium"
  13. border
  14. label-class-name="title-col"
  15. content-class-name="title-col"
  16. >
  17. <el-descriptions-item>
  18. <template slot="label"> 计划编号 </template>
  19. {{ info.code }}
  20. </el-descriptions-item>
  21. <el-descriptions-item>
  22. <template slot="label"> 计划类型 </template>
  23. {{ getDictValue('订单计划类型', info.planType) }}
  24. </el-descriptions-item>
  25. <el-descriptions-item>
  26. <template slot="label"> 产品编码</template>
  27. {{ info.productCode }}
  28. </el-descriptions-item>
  29. <el-descriptions-item>
  30. <template slot="label"> 牌号 </template>
  31. {{ info.brandNo }}
  32. </el-descriptions-item>
  33. <el-descriptions-item>
  34. <template slot="label"> 型号 </template>
  35. {{ info.model }}
  36. </el-descriptions-item>
  37. <el-descriptions-item>
  38. <template slot="label"> 规格 </template>
  39. {{ info.specification }}
  40. </el-descriptions-item>
  41. <el-descriptions-item>
  42. <template slot="label"> 销售单数量 </template>
  43. {{ info.codeNum }}
  44. </el-descriptions-item>
  45. <el-descriptions-item>
  46. <template slot="label"> 生产类型 </template>
  47. {{ info.produceVersionName }}
  48. </el-descriptions-item>
  49. <el-descriptions-item>
  50. <template slot="label"> 工艺路线 </template>
  51. {{ info.produceRoutingName }}
  52. </el-descriptions-item>
  53. <el-descriptions-item>
  54. <template slot="label"> 订单总数量 </template>
  55. {{ info.contractNum }}{{ info.measuringUnit }}
  56. </el-descriptions-item>
  57. <el-descriptions-item>
  58. <template slot="label"> 订单重量 </template>
  59. {{ info.sumOrderWeight }} {{ info.weightUnit }}
  60. </el-descriptions-item>
  61. <el-descriptions-item>
  62. <template slot="label"> 要求生产数量 </template>
  63. {{ Number(info.requiredFormingNum) }}{{ info.measuringUnit }}
  64. </el-descriptions-item>
  65. <el-descriptions-item>
  66. <template slot="label"> 要求生产重量 </template>
  67. {{ info.newSumOrderWeight }} {{ info.newWeightUnit }}
  68. </el-descriptions-item>
  69. <el-descriptions-item>
  70. <template slot="label"> 要求完成日期 </template>
  71. {{ info.reqMoldTime }}
  72. </el-descriptions-item>
  73. <el-descriptions-item>
  74. <template slot="label"> 批次号 </template>
  75. {{ info.batchNo }}
  76. </el-descriptions-item>
  77. <el-descriptions-item>
  78. <template slot="label"> 所属工厂 </template>
  79. {{ info.factoriesIdName }}
  80. </el-descriptions-item>
  81. <el-descriptions-item>
  82. <template slot="label"> 生产要求 </template>
  83. {{ info.productionRequirements }}
  84. </el-descriptions-item>
  85. <el-descriptions-item :span="3">
  86. <template slot="label"> </template>
  87. </el-descriptions-item>
  88. </el-descriptions>
  89. </div>
  90. <headerTitle title="计划列表" class="mt20" v-if="isAutoGenerateSubPlans">
  91. </headerTitle>
  92. <ele-pro-table
  93. ref="table2"
  94. :needPage="false"
  95. :columns="jsColumns"
  96. :datasource="jhList"
  97. tool-class="ele-toolbar-actions"
  98. max-height="360px"
  99. v-if="isAutoGenerateSubPlans"
  100. >
  101. <!-- <template v-slot:toolbar>
  102. <div class="toolbar_box">
  103. <el-button type="primary" size="mini" @click="handleAdd"
  104. >新增</el-button
  105. >
  106. </div>
  107. </template> -->
  108. <template v-slot:produceRoutingName="{ row }">
  109. <span>{{ row.produceRoutingName }}</span>
  110. </template>
  111. <template v-slot:startTime="{ row }">
  112. <el-date-picker
  113. class="w100"
  114. v-model="row.startTime"
  115. type="datetime"
  116. value-format="yyyy-MM-dd HH:mm:ss"
  117. placeholder="开始时间"
  118. @change="handleStartTimeChange(row)"
  119. disabled
  120. ></el-date-picker>
  121. </template>
  122. <template v-slot:endTime="{ row }">
  123. <el-date-picker
  124. class="w100"
  125. v-model="row.endTime"
  126. type="datetime"
  127. value-format="yyyy-MM-dd HH:mm:ss"
  128. @change="handleEndTimeChange(row)"
  129. placeholder="完成时间"
  130. disabled
  131. ></el-date-picker>
  132. </template>
  133. <template v-slot:requiredFormingNum="{ row }">
  134. <span>{{ row.requiredFormingNum }} {{ row.measuringUnit }}</span>
  135. </template>
  136. <template v-slot:action="{ row, $index }">
  137. <el-popconfirm
  138. class="ele-action"
  139. title="确定要删除这条数据吗?"
  140. @confirm="removeRow(row, $index)"
  141. >
  142. <template v-slot:reference>
  143. <el-link type="danger" :underline="false" icon="el-icon-delete">
  144. 删除
  145. </el-link>
  146. </template>
  147. </el-popconfirm>
  148. </template>
  149. </ele-pro-table>
  150. <div slot="footer" class="footer">
  151. <div>
  152. <el-button @click="cancel">取消</el-button>
  153. <el-button
  154. @click="submit(2)"
  155. type="primary"
  156. :loading="loading"
  157. v-if="type != 'edit'"
  158. >提交并发布</el-button
  159. >
  160. <el-button type="primary" @click="submit(1)" :loading="loading"
  161. >提交</el-button
  162. >
  163. </div>
  164. </div>
  165. </el-dialog>
  166. </template>
  167. <script>
  168. import { getCode } from '@/api/codeManagement';
  169. import dictMixins from '@/mixins/dictMixins';
  170. import { debounce } from 'lodash';
  171. import { parameterGetByCode } from '@/api/mainData/index';
  172. export default {
  173. mixins: [dictMixins],
  174. props: {
  175. info: Object,
  176. type: String
  177. },
  178. data() {
  179. return {
  180. visible: false,
  181. loading: false,
  182. tableList: [],
  183. isAutoGenerateSubPlans: false,
  184. jhList: [],
  185. jsColumns: [
  186. {
  187. columnKey: 'index',
  188. label: '序号',
  189. type: 'index',
  190. width: 55,
  191. align: 'center'
  192. },
  193. {
  194. prop: 'productCode',
  195. label: '编码',
  196. align: 'center',
  197. minWidth: 140
  198. },
  199. {
  200. prop: 'productName',
  201. label: '名称',
  202. align: 'center',
  203. minWidth: 140
  204. },
  205. {
  206. prop: 'brandNo',
  207. label: '牌号',
  208. align: 'center',
  209. showOverflowTooltip: true
  210. },
  211. {
  212. prop: 'specification',
  213. label: '规格',
  214. align: 'center',
  215. minWidth: 150,
  216. showOverflowTooltip: true
  217. },
  218. {
  219. prop: 'model',
  220. label: '型号',
  221. align: 'center',
  222. showOverflowTooltip: true
  223. },
  224. {
  225. slot: 'startTime',
  226. prop: 'startTime',
  227. label: '计划开始时间',
  228. align: 'center',
  229. minWidth: 180
  230. },
  231. {
  232. slot: 'endTime',
  233. prop: 'endTime',
  234. label: '计划完成时间',
  235. align: 'center',
  236. minWidth: 180
  237. },
  238. {
  239. prop: 'produceRoutingName',
  240. slot: 'produceRoutingName',
  241. label: '工艺路线',
  242. align: 'center',
  243. minWidth: 120
  244. },
  245. {
  246. prop: 'requiredFormingNum',
  247. label: '要求生产数量',
  248. align: 'center',
  249. slot: 'requiredFormingNum',
  250. width: 130
  251. }
  252. // {
  253. // columnKey: 'action',
  254. // label: '操作',
  255. // width: 90,
  256. // align: 'center',
  257. // fixed: 'right',
  258. // slot: 'action'
  259. // }
  260. ]
  261. };
  262. },
  263. computed: {},
  264. created() {
  265. this.requestDict('订单计划类型');
  266. this.getAutoGenerateSubPlans('auto_split_produce_plan');
  267. },
  268. methods: {
  269. open() {
  270. this.visible = true;
  271. if (this.type != 'edit') {
  272. this.getPlanCode();
  273. }
  274. if (this.isAutoGenerateSubPlans) {
  275. console.log(this.info, 'this.infothis.info');
  276. this.getJHListData(this.info);
  277. }
  278. },
  279. cancel() {
  280. this.visible = false;
  281. },
  282. async getAutoGenerateSubPlans(code) {
  283. await parameterGetByCode({ code }).then((res) => {
  284. this.isAutoGenerateSubPlans = res.value == '0' ? false : true;
  285. });
  286. },
  287. getJHListData(m) {
  288. for (let i = 0; i < this.jhList.length; i++) {
  289. let item = this.jhList[i];
  290. if (item.id == m.id) {
  291. return;
  292. }
  293. }
  294. let row = {};
  295. // if (
  296. // m.processRoute &&
  297. // m.processRoute.list &&
  298. // m.processRoute.list.length > 0
  299. // ) {
  300. // row = m.processRoute.list[0];
  301. // }
  302. // let _num =
  303. // ((this.formData.requiredFormingNum || 0) / (this.baseCount || 0)) *
  304. // m.dosage;
  305. // _num = _num.toFixed(3);
  306. // _num = this.formattedNum(_num);
  307. let data = {
  308. id: m.id,
  309. categoryId: m.categoryId,
  310. productCode: m.productCode,
  311. productName: m.productName,
  312. brandNo: m.brandNo,
  313. specification: m.specification,
  314. model: m.model,
  315. produceRoutingName: m.produceRoutingName || '',
  316. productUnitWeight: m.productUnitWeight,
  317. requiredFormingNum: m.requiredFormingNum,
  318. measuringUnit: m.measuringUnit,
  319. startTime: m.startTime || '',
  320. endTime: m.endTime || '',
  321. unit: this.unit,
  322. resourceType: 0
  323. };
  324. this.jhList.push(data);
  325. },
  326. async getPlanCode() {
  327. this.loading = true;
  328. try {
  329. const code = await getCode('product_code');
  330. this.$set(this.info, 'code', code);
  331. } catch (err) {}
  332. this.loading = false;
  333. },
  334. submit: debounce(function (type) {
  335. this.$emit('publish', type);
  336. this.visible = false;
  337. }, 800)
  338. }
  339. };
  340. </script>
  341. <style lang="scss">
  342. .basic-details-title {
  343. margin: 10px 0;
  344. }
  345. .title-col {
  346. color: #000000 !important;
  347. background-color: #fff;
  348. }
  349. </style>