plan-view.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. <template>
  2. <div class="plan-view">
  3. <div class="description">
  4. <div class="label"></div>
  5. <!-- <div class="label">方案说明</div>
  6. <div class="content">
  7. <template v-for="(item, index) in rulesList">
  8. <template v-for="(itm, idx) in item.list">
  9. <template v-if="!itm.lastDisabled">
  10. <div class="tag" :key="index + '' + idx">{{ itm.label }}</div>
  11. </template>
  12. </template>
  13. </template>
  14. </div> -->
  15. <div class="operate">
  16. <el-button type="primary" plain @click="handleRelease"
  17. >发布当前方案</el-button
  18. >
  19. <!-- <el-button type="primary">保存</el-button> -->
  20. </div>
  21. </div>
  22. <div class="display-box">
  23. <el-button type="primary" plain size="small" @click="addOrder"
  24. >添加工单</el-button
  25. >
  26. <!-- <el-button type="primary" plain size="small">删除</el-button> -->
  27. <div class="items">
  28. <span class="label">累计工单条数</span>
  29. {{ tableData.length }}条
  30. </div>
  31. <div class="items">
  32. <span class="label">累计成型数量</span>
  33. {{ sumData.formingNum }}pcs
  34. </div>
  35. <div class="items">
  36. <span class="label">累计成型重量</span>
  37. {{ sumData.formingWeight }}{{ infoData.productUnitWeight }}
  38. </div>
  39. <div class="items">
  40. <span class="label">设备数量</span>
  41. 14条
  42. </div>
  43. <!-- <div class="items">
  44. <span class="label">成型剂需求</span>
  45. 14条
  46. </div>
  47. <div class="items">
  48. <span class="label">混合料需求</span>
  49. 14条
  50. </div> -->
  51. </div>
  52. <el-form :model="{ tableData }" label-width="0" ref="formRef">
  53. <el-table :data="tableData">
  54. <el-table-column type="index" label="序号"></el-table-column>
  55. <el-table-column label="工单号" prop="code"></el-table-column>
  56. <el-table-column label="成型数量" prop="">
  57. <template v-slot="{ row, $index }">
  58. <el-form-item
  59. :prop="`tableData.${$index}.formingNum`"
  60. :rules="rule.formingNum"
  61. >
  62. <el-input
  63. type="number"
  64. v-model.number="row.formingNum"
  65. ></el-input>
  66. </el-form-item>
  67. </template>
  68. </el-table-column>
  69. <el-table-column label="成型重量" prop="">
  70. <template v-slot="{ row, $index }">
  71. <el-form-item
  72. :prop="`tableData.${$index}.formingWeight`"
  73. :rules="rule.formingWeight"
  74. >
  75. <el-input
  76. type="number"
  77. v-model.number="row.formingWeight"
  78. ></el-input>
  79. </el-form-item>
  80. </template>
  81. </el-table-column>
  82. <el-table-column label="开始日期" prop="">
  83. <template v-slot="{ row, $index }">
  84. <el-form-item
  85. :prop="`tableData.${$index}.planStartTime`"
  86. :rules="rule.planStartTime"
  87. >
  88. <el-date-picker
  89. class="w100"
  90. :clearable="false"
  91. v-model="row.planStartTime"
  92. :disabledDate="() => time.getTime() >= row.planCompleteDate"
  93. type="date"
  94. placeholder="选择日期"
  95. value-format="yyyy-MM-dd HH:mm:ss"
  96. >
  97. </el-date-picker>
  98. </el-form-item>
  99. </template>
  100. </el-table-column>
  101. <el-table-column label="班次" prop="">
  102. <template v-slot="{ row, $index }">
  103. <el-form-item
  104. :prop="`tableData.${$index}.classeId`"
  105. :rules="rule.classeId"
  106. >
  107. <classesSelect
  108. v-model="row.classeId"
  109. @selfChange="(val) => handleClasseChange(val, row)"
  110. />
  111. </el-form-item>
  112. </template>
  113. </el-table-column>
  114. <el-table-column label="设备编码" prop="deviceCode"></el-table-column>
  115. <el-table-column label="设备名称" prop="deviceName">
  116. <template v-slot="{ row, $index }">
  117. <el-input
  118. :value="row.deviceName"
  119. @click.native="editOrder(row)"
  120. ></el-input>
  121. </template>
  122. </el-table-column>
  123. <el-table-column
  124. label="可执行人"
  125. prop="executorName"
  126. min-width="220px"
  127. show-overflow-tooltip
  128. >
  129. <template v-slot="{ row, $index }">
  130. <template v-if="row.executorName.length">
  131. <el-tag
  132. type="success"
  133. v-for="(item, index) in row.executorName.split(',')"
  134. :key="index"
  135. >{{ item }}</el-tag
  136. >
  137. </template>
  138. </template></el-table-column
  139. >
  140. <el-table-column label="操作" prop="">
  141. <template v-slot="{ $index }">
  142. <el-link type="danger" @click="handleDelete($index)">删除</el-link>
  143. </template>
  144. </el-table-column>
  145. <el-table-column type="selection"></el-table-column>
  146. </el-table>
  147. </el-form>
  148. <equipmentDailog
  149. ref="equipmentDailogRef"
  150. @success="equipmentSelect"
  151. :produceVersionId="infoData.produceVersionId"
  152. />
  153. </div>
  154. </template>
  155. <script>
  156. import equipmentDailog from './equipment-dailog.vue';
  157. import classesSelect from '@/components/CommomSelect/classes-select';
  158. import { getExector } from '@/api/workforceManagement/classes';
  159. import { release } from '@/api/productionPlan/order.js';
  160. import { getCode } from '@/api/codeManagement';
  161. export default {
  162. components: { equipmentDailog, classesSelect },
  163. props: {
  164. infoData: {
  165. type: Object,
  166. default: () => ({})
  167. },
  168. orderList: {
  169. type: Array,
  170. default: () => []
  171. }
  172. },
  173. data () {
  174. return {
  175. tableData: [],
  176. rule: {
  177. formingNum: [
  178. { required: true, message: '请输入成型数量', trigger: 'blur' }
  179. ],
  180. formingWeight: [
  181. { required: true, message: '请输入成型重量', trigger: 'blur' }
  182. ],
  183. planStartTime: [
  184. { required: true, message: '请选择开始日期', trigger: 'blur' }
  185. ],
  186. classeId: [
  187. { required: true, message: '请选择班次', trigger: 'change' }
  188. ]
  189. },
  190. rulesList: [
  191. {
  192. type: 'radio',
  193. value: '',
  194. list: [
  195. { label: '多设备优先', value: 0 },
  196. { label: '多班次优先', value: 1 }
  197. ]
  198. },
  199. {
  200. type: 'checked',
  201. value: [],
  202. list: [
  203. { label: '设备产能优先', value: 0 },
  204. { label: '最早开始时间优先', value: 1 },
  205. { label: '开始时间优先', value: 2, lastDisabled: true }
  206. ]
  207. },
  208. {
  209. type: 'checked',
  210. value: [],
  211. list: [
  212. { label: '非空闲设备可用', value: 0 },
  213. { label: '检修设备可用', value: 1 },
  214. { label: '检修设备优先', value: 1, lastDisabled: true }
  215. ]
  216. },
  217. {
  218. type: 'radio',
  219. value: '',
  220. list: [{ label: '末单均衡', value: 0 }]
  221. }
  222. ]
  223. };
  224. },
  225. computed: {
  226. sumData () {
  227. let formingNum = 0;
  228. let formingWeight = 0;
  229. this.tableData.forEach((ele) => {
  230. formingNum += ele.formingNum || 0;
  231. formingWeight += ele.formingWeight || 0;
  232. });
  233. return { formingNum, formingWeight };
  234. }
  235. },
  236. watch: {
  237. orderList: {
  238. immediate: true,
  239. handler () {
  240. if (this.orderList?.length) {
  241. this.tableData = this.orderList;
  242. }
  243. }
  244. }
  245. },
  246. methods: {
  247. // 发布
  248. handleRelease () {
  249. this.$refs.formRef.validate((value) => {
  250. if (value) {
  251. this.$confirm('发布工单后不可撤回,确定发布吗?', '发布确认').then(
  252. async () => {
  253. await release(this.tableData);
  254. this.$message.success('发布成功!');
  255. this.$router.go(-1);
  256. }
  257. );
  258. }
  259. });
  260. },
  261. // 班次改变选择执行人
  262. async handleClasseChange (val, row) {
  263. const res = await getExector(val);
  264. let executorId = '';
  265. let executorName = '';
  266. res.forEach((item) => {
  267. executorId += ',' + item.userVOList.map((itm) => itm.id).join(',');
  268. executorName +=
  269. ',' + item.userVOList.map((itm) => itm.name).join(',');
  270. });
  271. row.executorId = executorId.substring(1);
  272. row.executorName = executorName.substring(1);
  273. },
  274. addOrder () {
  275. this.$refs.equipmentDailogRef.open();
  276. },
  277. editOrder (row) {
  278. this.$refs.equipmentDailogRef.openSingle([row], (current) => {
  279. row.deviceCode = current.code;
  280. row.deviceId = current.id;
  281. row.deviceName = current.name;
  282. row.planStartTime = current.planCompleteDate;
  283. row.planCompleteDate = current.planCompleteDate;
  284. });
  285. },
  286. async equipmentSelect (list) {
  287. for (const pre of list) {
  288. const code = await getCode('product_order_code');
  289. // classeId 班次id false
  290. // classeName 班次名称 false
  291. // code 工单号 false
  292. // deviceCode 设备编码 false
  293. // deviceId 设备id false
  294. // deviceName 设备名称 false
  295. // executorId 执行人id false
  296. // executorName 执行人名称 false
  297. // formingNum 成型数量 false
  298. // generativeRules 生成规则 false
  299. // planCompleteTime 计划完成时间 false
  300. // planStartTime 计划开始时间 false
  301. // productionPlanCode 生产计划号 false
  302. // productionPlanId 生产计划id false
  303. // workOrderType 工单类型
  304. this.tableData.push({
  305. classeId: pre.classeId,
  306. code: code,
  307. deviceCode: pre.code,
  308. deviceId: pre.id,
  309. deviceName: pre.name,
  310. executorId: '',
  311. executorName: '',
  312. planCompleteTime: '', //当班下班时间,
  313. planStartTime: pre.planCompleteDate,
  314. planCompleteDate: pre.planCompleteDate,
  315. formingNum: pre.formingNum,
  316. formingWeight: '',
  317. productionPlanId: this.infoData.id,
  318. productionPlanCode: this.infoData.code,
  319. produceVersionId: this.infoData.produceVersionId
  320. });
  321. }
  322. },
  323. handleDelete (index) {
  324. this.tableData.splice(index, 1);
  325. }
  326. }
  327. };
  328. </script>
  329. <style lang="scss" scoped>
  330. .plan-view {
  331. ::v-deep(.el-form-item) {
  332. margin-top: 16px;
  333. margin-bottom: 16px;
  334. }
  335. }
  336. .description {
  337. display: flex;
  338. justify-content: space-between;
  339. align-items: center;
  340. padding: 10px 20px;
  341. border: 1px solid rgba(215, 215, 215, 1);
  342. background-color: rgba(242, 242, 242, 1);
  343. .label {
  344. margin-right: 20px;
  345. }
  346. .content {
  347. flex: 1;
  348. display: flex;
  349. justify-content: flex-start;
  350. align-items: center;
  351. .tag {
  352. padding: 5px 10px;
  353. background-color: rgba(202, 249, 130, 1);
  354. border-radius: 20px;
  355. & + .tag {
  356. margin-left: 10px;
  357. }
  358. }
  359. }
  360. }
  361. .display-box {
  362. display: flex;
  363. justify-content: flex-start;
  364. align-items: center;
  365. padding: 10px;
  366. .items {
  367. margin-left: 30px;
  368. .label {
  369. font-weight: bold;
  370. }
  371. }
  372. }
  373. </style>