releaseDialog.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771
  1. <template>
  2. <ele-modal
  3. :width="modelWidth"
  4. :visible.sync="dispatchVisible"
  5. :close-on-click-modal="false"
  6. custom-class="ele-dialog-form dispatch-tech-dialog"
  7. :maxable="true"
  8. :title="'派单'"
  9. append-to-body
  10. :before-close="cancel"
  11. >
  12. <div class="form-wrapper">
  13. <el-form
  14. ref="form"
  15. :model="form"
  16. :inline="true"
  17. label-position="right"
  18. label-width="100px"
  19. >
  20. <el-row :gutter="10" class="basic" type="flex" style="flex-wrap: wrap">
  21. <el-col
  22. :xs="12"
  23. :sm="12"
  24. :md="12"
  25. :lg="8"
  26. :xl="6"
  27. v-for="item in fieldList"
  28. :key="item.prop"
  29. >
  30. <el-form-item :label="item.label">
  31. <el-date-picker
  32. class="w100"
  33. v-model="current[item.prop]"
  34. type="datetime"
  35. value-format="yyyy-MM-dd HH:mm:ss"
  36. v-if="item.type == 'date'"
  37. placeholder=" "
  38. :disabled="true"
  39. ></el-date-picker>
  40. <el-input :value="fieldValue(item.prop)" disabled v-else />
  41. </el-form-item>
  42. </el-col>
  43. </el-row>
  44. <el-row :gutter="10">
  45. <el-col :xs="12" :sm="12" :md="12" :lg="8" :xl="6">
  46. <el-form-item label="所属工厂:">
  47. <el-input v-model="form.factoryName" :disabled="true"> </el-input>
  48. </el-form-item>
  49. </el-col>
  50. <el-col :xs="12" :sm="12" :md="12" :lg="8" :xl="6">
  51. <el-form-item label="所属工作中心:">
  52. <el-select
  53. style="width: 100%"
  54. v-model="form.workCenterId"
  55. placeholder="请选择"
  56. @change="changeWork"
  57. >
  58. <el-option
  59. v-for="item in workCenterList"
  60. :key="item.id"
  61. :label="item.name"
  62. :value="item.id"
  63. >
  64. </el-option>
  65. </el-select>
  66. </el-form-item>
  67. </el-col>
  68. <el-col :xs="12" :sm="12" :md="12" :lg="8" :xl="6">
  69. <el-form-item label="所属班组:" required>
  70. <el-select
  71. style="width: 100%"
  72. v-model="form.teamId"
  73. placeholder="请选择"
  74. @change="changeGroups"
  75. >
  76. <el-option
  77. v-for="item in teamList"
  78. :key="item.id"
  79. :label="item.name"
  80. :value="item.id"
  81. >
  82. </el-option>
  83. </el-select>
  84. </el-form-item>
  85. </el-col>
  86. <el-col :xs="12" :sm="12" :md="12" :lg="8" :xl="6">
  87. <el-form-item label="班组长:">
  88. <el-input
  89. v-model="form.leaderUserName"
  90. :disabled="true"
  91. placeholder="-"
  92. >
  93. </el-input>
  94. </el-form-item>
  95. </el-col>
  96. </el-row>
  97. <el-row>
  98. <el-form-item label="报工类型:" required>
  99. <el-radio-group
  100. v-model="form.singleReport"
  101. :disabled="form.isDisable"
  102. >
  103. <!-- v-if="clientEnvironmentId != 2" -->
  104. <el-radio :label="1" :disabled="singleDis">单件报工</el-radio>
  105. <el-radio :label="0" :disabled="batchDis">批量报工</el-radio>
  106. </el-radio-group>
  107. </el-form-item>
  108. </el-row>
  109. <el-row>
  110. <el-form-item label="派单方式:" prop="taskAss">
  111. <!-- @change="changeDispatch" -->
  112. <el-radio-group v-model="form.taskAss" :disabled="form.isDisable">
  113. <el-radio :label="1" :disabled="orderDis">生产订单派单</el-radio>
  114. <el-radio :label="0" :disabled="procTaskDis"
  115. >工序任务派单</el-radio
  116. >
  117. </el-radio-group>
  118. </el-form-item>
  119. </el-row>
  120. <el-row v-if="form.taskAss == 1">
  121. <el-col :span="24">
  122. <el-form-item label="指派:" prop="assignType">
  123. <el-radio-group
  124. v-model="form.assignType"
  125. size="mini"
  126. @change="assignRadio"
  127. :disabled="form.isDisable"
  128. >
  129. <el-radio-button :label="1">工位</el-radio-button>
  130. <!-- <el-radio-button :label="2">人员</el-radio-button> -->
  131. <el-radio-button :label="3">产线</el-radio-button>
  132. </el-radio-group>
  133. </el-form-item>
  134. </el-col>
  135. <el-form-item required label="工位:" v-if="form.assignType == 1">
  136. <el-select
  137. class="ele-block"
  138. v-model="form.workstationIds"
  139. placeholder="请选择工位"
  140. size="mini"
  141. multiple
  142. filterable
  143. :disabled="form.isDisable"
  144. >
  145. <el-option
  146. v-for="item in stationList"
  147. :key="item.id"
  148. :label="item.name + '(' + item.code + ')'"
  149. :value="item.id"
  150. >
  151. </el-option>
  152. </el-select>
  153. </el-form-item>
  154. <el-form-item label="人员:" v-if="form.assignType == 2">
  155. <el-select
  156. class="ele-block"
  157. v-model="form.crewIds"
  158. placeholder="请选择人员"
  159. size="mini"
  160. filterable
  161. multiple
  162. >
  163. <el-option
  164. v-for="item in crewList"
  165. :key="item.id"
  166. :label="item.name"
  167. :value="item.id"
  168. >
  169. </el-option>
  170. </el-select>
  171. </el-form-item>
  172. <el-form-item label="产线:" v-if="form.assignType == 3" required>
  173. <el-select
  174. class="ele-block"
  175. v-model="form.factoryLineIds"
  176. placeholder="请选择产线"
  177. size="mini"
  178. filterable
  179. multiple
  180. >
  181. <el-option
  182. v-for="item in productionList"
  183. :key="item.id"
  184. :label="item.name"
  185. :value="item.id"
  186. >
  187. </el-option>
  188. </el-select>
  189. </el-form-item>
  190. </el-row>
  191. <el-tabs
  192. class="process_list"
  193. v-model="processId"
  194. type="border-card"
  195. @tab-click="handleClick"
  196. v-show="form.taskAss == 0"
  197. v-loading="tabsLoading"
  198. >
  199. <el-tab-pane
  200. v-for="(item, index) in processList"
  201. :key="item.id"
  202. :label="item.name"
  203. :name="item.id"
  204. >
  205. <span style="color: green">
  206. 工序编码:{{ item.code }},所属工作中心:{{
  207. item.workCenterName
  208. }}</span
  209. >
  210. <ele-pro-table
  211. class="table"
  212. :ref="`tableRef${index}`"
  213. :columns="columns(item)"
  214. :datasource="item.list"
  215. cache-key="systemRoleTable"
  216. :pageSize="20"
  217. v-loading="tabLoading"
  218. :selection.sync="item.selection"
  219. row-key="id"
  220. >
  221. <template v-slot:toolbar>
  222. <el-button
  223. type="primary"
  224. @click="dispatch(item, 1)"
  225. :loading="toolbarLoading"
  226. :disabled="!item.isDisable"
  227. >
  228. 派单
  229. </el-button>
  230. <el-button
  231. type="primary"
  232. @click="dispatch(item, 2)"
  233. :loading="toolbarLoading"
  234. :disabled="!item.isDisable"
  235. >
  236. 撤回
  237. </el-button>
  238. <el-button
  239. type="primary"
  240. @click="dispatch(item, 3)"
  241. :loading="toolbarLoading"
  242. :disabled="!item.isDisable"
  243. >
  244. 保存
  245. </el-button>
  246. <el-button
  247. type="success"
  248. @click="addStation(item, index)"
  249. :loading="toolbarLoading"
  250. :disabled="!item.isDisable || item.assignType == 3"
  251. >
  252. 添加工位
  253. </el-button>
  254. <div style="margin-left: 50px; display: inline-block">
  255. <span
  256. class="text"
  257. style="
  258. font-weight: bold;
  259. font-size: 14px;
  260. margin-right: 8px;
  261. "
  262. >指派:</span
  263. >
  264. <el-radio-group
  265. v-model="item.assignType"
  266. size="mini"
  267. @change="(e) => changeRadio(e, index)"
  268. >
  269. <el-radio-button
  270. :label="1"
  271. :disabled="radioBun(item, 'stationDis')"
  272. >工位</el-radio-button
  273. >
  274. <!-- <el-radio-button
  275. :label="2"
  276. :disabled="radioBun(item, 'staffDis')"
  277. >人员</el-radio-button
  278. > -->
  279. <el-radio-button
  280. :label="3"
  281. :disabled="radioBun(item, 'lineDis')"
  282. >产线</el-radio-button
  283. >
  284. </el-radio-group>
  285. </div>
  286. <div
  287. style="margin-left: 50px; display: inline-block"
  288. v-if="timeSlot(item)"
  289. >
  290. 时间段: {{ item.startDate }} ----- {{ item.endDate }}
  291. </div>
  292. </template>
  293. <template v-slot:quantity="{ row }">
  294. <el-input
  295. :disabled="permissions(row)"
  296. type="number"
  297. v-model="row.quantity"
  298. placeholder="请输入数量"
  299. @input="(e) => handleQuantityInput(e, row, item)"
  300. ></el-input>
  301. </template>
  302. <template v-slot:weight="{ row }">
  303. <el-input
  304. :disabled="permissions(row)"
  305. type="number"
  306. v-model="row.weight"
  307. placeholder="请输入重量"
  308. @input="(e) => handleWeightInput(e, row, item)"
  309. ></el-input>
  310. </template>
  311. <template v-slot:teamTimeIds="{ row }">
  312. <el-select
  313. :disabled="permissions(row)"
  314. multiple
  315. v-model="row.teamTimeIds"
  316. placeholder="班次"
  317. @change="(e) => shiftSelection(e, row, item)"
  318. >
  319. <el-option
  320. v-for="item in shiftList"
  321. :key="item.id"
  322. :label="item.dutyName"
  323. :value="item.id"
  324. >
  325. </el-option>
  326. </el-select>
  327. </template>
  328. <template v-slot:startTime="{ row }">
  329. <el-date-picker
  330. :disabled="permissions(row)"
  331. class="w100"
  332. v-model="row.startTime"
  333. type="datetime"
  334. value-format="yyyy-MM-dd HH:mm:ss"
  335. placeholder="开始时间"
  336. @change="handleStartTimeChange(row, item)"
  337. ></el-date-picker>
  338. </template>
  339. <template v-slot:endTime="{ row }">
  340. <el-date-picker
  341. :disabled="permissions(row)"
  342. class="w100"
  343. v-model="row.endTime"
  344. type="datetime"
  345. value-format="yyyy-MM-dd HH:mm:ss"
  346. @change="handleEndTimeChange(row, item)"
  347. placeholder="完成时间"
  348. ></el-date-picker>
  349. </template>
  350. <template v-slot:action="{ row }">
  351. <!-- :disabled="resetBtnDis(row)" -->
  352. <el-link
  353. v-if="canDeleteAddedStation(row)"
  354. type="danger"
  355. :underline="false"
  356. style="margin-right: 8px"
  357. @click="deleteRow(row, item)"
  358. >
  359. 删除
  360. </el-link>
  361. <el-popconfirm
  362. title="确定要重置该条数据吗?"
  363. @confirm="resetData(row, item)"
  364. v-if="resetBtnDis(row)"
  365. >
  366. <template v-slot:reference>
  367. <el-link type="primary" :underline="false"> 重置 </el-link>
  368. </template>
  369. </el-popconfirm>
  370. </template>
  371. </ele-pro-table>
  372. </el-tab-pane>
  373. </el-tabs>
  374. </el-form>
  375. </div>
  376. <div slot="footer">
  377. <el-button plain @click="cancel" :disabled="form.isDisable"
  378. >取消</el-button
  379. >
  380. <el-button
  381. type="primary"
  382. @click="confirm"
  383. :loading="toolbarLoading"
  384. :disabled="form.isDisable"
  385. >确定</el-button
  386. >
  387. </div>
  388. <choose-station
  389. ref="chooseStationRef"
  390. @chooseStationList="chooseStationList"
  391. ></choose-station>
  392. </ele-modal>
  393. </template>
  394. <script>
  395. import releaseMixin from '../mixins/release';
  396. import { parameterGetByCode } from '@/api/mainData/index';
  397. import chooseStation from './chooseStation.vue';
  398. export default {
  399. components: {
  400. chooseStation
  401. },
  402. props: {
  403. current: {
  404. type: Object,
  405. default: () => {}
  406. },
  407. dispatchVisible: {
  408. type: Boolean,
  409. default: false
  410. }
  411. },
  412. mixins: [releaseMixin],
  413. mixinOptions: { type: 'add' },
  414. data() {
  415. return {
  416. processId: '',
  417. tabLoading: false,
  418. dynamicName: '工位名称',
  419. form: {
  420. assignType: '',
  421. crewIds: '',
  422. workstationIds: '',
  423. teamId: '',
  424. singleReport: '',
  425. workCenterId: '',
  426. taskAss: '',
  427. factoryName: '',
  428. factoryLineIds: '',
  429. isDisable: false
  430. },
  431. processingRequired: 0,
  432. toolbarLoading: false,
  433. processList: [],
  434. workCenterList: [],
  435. teamList: [],
  436. tabsLoading: false,
  437. stationList: [], // 工位的数据
  438. productionList: [], // 产线的数据
  439. crewList: [], // 人员的数据
  440. procTaskDis: false, // 工序任务派单选择
  441. firstTaskindex: '', // 首工序id 对应的工序列表数据下标
  442. fieldList: [
  443. { label: '生产订单号:', prop: 'code' },
  444. { label: '计划编号:', prop: 'productionPlanCode' },
  445. { label: '工艺路线:', prop: 'produceRoutingName' },
  446. // { label: '编码', prop: 'productCode' },
  447. { label: '名称:', prop: 'productName' },
  448. { label: '生产编号:', prop: 'productionCodes' },
  449. { label: '牌号:', prop: 'brandNo' },
  450. { label: '批次号:', prop: 'batchNo' },
  451. { label: '型号:', prop: 'model' },
  452. { label: '要求生产数量:', prop: 'formingNum' },
  453. { label: '要求生产重量:', prop: 'initialWeight' },
  454. { label: '计划开始时间:', prop: 'planStartTime', type: 'date' },
  455. { label: '计划结束时间:', prop: 'planCompleteTime', type: 'date' }
  456. ],
  457. shiftList: [],
  458. dateValue: '',
  459. orderDis: false, // 生产订单派单
  460. singleDis: false, // 单个报工
  461. batchDis: false, // 批量报工
  462. isDispatchRow: {}, // 查询是否派单数据
  463. time_calc_code: '0', // 是否进行时间赋值 0 否 1 是
  464. isTask: true
  465. };
  466. },
  467. computed: {
  468. fieldValue() {
  469. return (field) => {
  470. return this.current[field];
  471. };
  472. },
  473. clientEnvironmentId() {
  474. return this.$store.state.user.info.clientEnvironmentId;
  475. },
  476. userInfo() {
  477. return this.$store.state.user.info;
  478. },
  479. modelWidth() {
  480. // if(this.form.taskAss == 1){
  481. // return '1000px'
  482. // }
  483. return '75vw';
  484. },
  485. // 重置按钮 的置灰权限 没有进行操作跟派单的数据 置灰
  486. resetBtnDis() {
  487. return (row) => {
  488. if (!row.status) return false;
  489. let flag = row.status.code != 1;
  490. return flag;
  491. };
  492. },
  493. // 指派单选框操作 已派单的 其它两个按钮不能操作
  494. radioBun() {
  495. return (row, type) => {
  496. if (!row.radioBun) return false;
  497. let flag = row.radioBun[type];
  498. return flag;
  499. };
  500. },
  501. // 列表输入框操作 已派单的不能操作
  502. permissions() {
  503. return (row) => {
  504. if (!row.status) return false;
  505. if (row.status.code == 1) return true;
  506. };
  507. },
  508. // 时间段显示
  509. timeSlot() {
  510. return (item) => {
  511. if (!item.startDate || !item.endDate) {
  512. return false;
  513. }
  514. return true;
  515. };
  516. },
  517. columns() {
  518. return (val) => {
  519. let data =
  520. val.assignType == 1
  521. ? [
  522. {
  523. prop: 'assetCode',
  524. label: '设备编码',
  525. align: 'center',
  526. width: 150
  527. },
  528. {
  529. prop: 'assetName',
  530. label: '设备名称',
  531. align: 'center',
  532. width: 150
  533. },
  534. {
  535. prop: 'assetModelType',
  536. label: '设备型号',
  537. align: 'center',
  538. width: 150
  539. },
  540. {
  541. prop: 'assetCategoryLevelPath',
  542. label: '设备类型',
  543. align: 'center',
  544. width: 150
  545. }
  546. ]
  547. : [];
  548. return [
  549. {
  550. columnKey: 'index',
  551. label: '序号',
  552. type: 'index',
  553. width: 55,
  554. align: 'center',
  555. fixed: 'left'
  556. },
  557. {
  558. width: 45,
  559. type: 'selection',
  560. columnKey: 'selection',
  561. align: 'center',
  562. fixed: 'left',
  563. reserveSelection: true
  564. },
  565. {
  566. prop: 'name',
  567. label: this.dynamicName,
  568. align: 'center',
  569. width: 200
  570. },
  571. {
  572. prop: 'code',
  573. label: '编码',
  574. align: 'center',
  575. width: 200
  576. },
  577. ...data,
  578. {
  579. prop: 'status',
  580. label: '状态',
  581. align: 'center',
  582. width: 150,
  583. formatter: (row) => {
  584. if (!row.status) return '';
  585. return row.status.desc || '';
  586. }
  587. },
  588. {
  589. slot: 'quantity',
  590. prop: 'quantity',
  591. label: '数量',
  592. align: 'center',
  593. width: 140
  594. },
  595. {
  596. slot: 'weight',
  597. prop: 'weight',
  598. label: `重量(${this.current.newWeightUnit})`,
  599. align: 'center',
  600. width: 140
  601. },
  602. {
  603. slot: 'teamTimeIds',
  604. prop: 'teamTimeIds',
  605. label: '班次',
  606. align: 'center',
  607. minWidth: 220
  608. },
  609. {
  610. slot: 'startTime',
  611. prop: 'startTime',
  612. label: '计划开始时间',
  613. align: 'center',
  614. minWidth: 240
  615. },
  616. {
  617. slot: 'endTime',
  618. prop: 'endTime',
  619. label: '计划完成时间',
  620. align: 'center',
  621. minWidth: 240
  622. },
  623. {
  624. columnKey: 'action',
  625. label: '操作',
  626. width: 120,
  627. align: 'center',
  628. resizable: false,
  629. fixed: 'right',
  630. slot: 'action'
  631. }
  632. ];
  633. };
  634. }
  635. },
  636. watch: {},
  637. created() {
  638. this.getDispatchMethod('dispatch_method');
  639. this.getAssignmentMethod('assignment_method');
  640. this.getReportType('report_type');
  641. // 时间计算规则code
  642. this.getCode();
  643. this.workCenterData(); // 查询工作中心
  644. this.getClassesData(); // 查询班次
  645. this.queryCheckExists(); // 查询是否派单
  646. // this.form.singleReport = this.clientEnvironmentId == 2 ? 0 : '';
  647. this.dateValue = this.getFormattedDate();
  648. },
  649. methods: {
  650. getCode() {
  651. parameterGetByCode({
  652. code: 'time_calculation_rules'
  653. }).then((res) => {
  654. if (res) {
  655. this.time_calc_code = res.value || '0';
  656. }
  657. });
  658. },
  659. async getReportType(code) {
  660. await parameterGetByCode({ code }).then((res) => {
  661. if (res) {
  662. this.form.singleReport =
  663. this.clientEnvironmentId == 2
  664. ? 0
  665. : res.value == '0'
  666. ? 0
  667. : res.value == '1'
  668. ? 1
  669. : '';
  670. console.log(this.form.singleReport, 'this.form.singleReport');
  671. }
  672. });
  673. },
  674. async getDispatchMethod(code) {
  675. await parameterGetByCode({ code }).then((res) => {
  676. if (res) {
  677. this.form.taskAss = res.value == '0' ? 0 : 1;
  678. console.log(this.form.taskAss, 'this.form.taskAss');
  679. }
  680. });
  681. },
  682. async getAssignmentMethod(code) {
  683. await parameterGetByCode({ code }).then((res) => {
  684. if (res) {
  685. this.form.assignType =
  686. res.value == '0' ? 1 : res.value == '1' ? 1 : 3;
  687. }
  688. });
  689. }
  690. }
  691. };
  692. </script>
  693. <style lang="scss" scoped>
  694. .top-box {
  695. display: flex;
  696. margin-bottom: 10px;
  697. .item-box {
  698. flex: 1;
  699. }
  700. }
  701. .radio-box {
  702. margin: 10px 0;
  703. }
  704. .table {
  705. margin-top: 20px;
  706. }
  707. ::v-deep .el-radio-button__orig-radio:checked + .el-radio-button__inner {
  708. background-color: #10d070;
  709. border-color: #10d070;
  710. }
  711. ::v-deep .el-radio-button__orig-radio:checked + .el-radio-button__inner {
  712. box-shadow: none;
  713. }
  714. // ::v-deep .ele-block{
  715. // width: 240px;
  716. // }
  717. // ::v-deep .basic {
  718. // .el-form-item {
  719. // width: 100%;
  720. // }
  721. // .form80 {
  722. // .el-form-item__content {
  723. // width: calc(100% - 80px);
  724. // }
  725. // }
  726. // .form65 {
  727. // .el-form-item__content {
  728. // width: calc(100% - 65px);
  729. // }
  730. // }
  731. // .el-form-item__label {
  732. // padding: 0 4px 0 0;
  733. // }
  734. // .item_label {
  735. // white-space: nowrap;
  736. // overflow: hidden;
  737. // text-overflow: ellipsis;
  738. // width: 100%;
  739. // }
  740. // }
  741. </style>
  742. <style lang="scss">
  743. @import './dispatch-tech-dialog.scss';
  744. </style>