index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never" v-loading="loading">
  4. <order-search @search="reload" ref="searchRef"> </order-search>
  5. <!-- <el-tabs v-model="activeName" type="card">
  6. <el-tab-pane label="未完成工单" name="first"></el-tab-pane>
  7. <el-tab-pane label="已完成工单" name="second"></el-tab-pane>
  8. </el-tabs> -->
  9. <!-- 数据表格 -->
  10. <!-- <plan-statistics></plan-statistics> -->
  11. <!-- <ele-pro-table
  12. ref="table"
  13. :columns="newColumns"
  14. :datasource="datasource"
  15. cache-key="workOrderTable"
  16. row-key="code"
  17. @sort-change="onSortChange"
  18. height="calc(100vh - 380px)"
  19. autoAmendPage
  20. :parse-data="parseData"
  21. > -->
  22. <ele-pro-table ref="table" :columns="newColumns" :datasource="datasource" cache-key="workOrderTable" row-key="id"
  23. @sort-change="onSortChange" autoAmendPage :parse-data="parseData" :cache-key="cacheKeyUrl" @columns-change="handleColumnChange"
  24. >
  25. <!-- :key="activeName" -->
  26. <!-- :selection.sync="selection" -->
  27. <!-- @update:selection="handleSelectionChange" -->
  28. <template v-slot:code="{ row }">
  29. {{ row.code }}
  30. </template>
  31. <template v-slot:formingWeight="{ row }">
  32. {{ row.formingWeight }} {{ row.newWeightUnit }}
  33. </template>
  34. <template v-slot:priority="{ row }">
  35. <div style="display: flex">
  36. <el-input v-model="row.priority" type="number" size="mini" :min="0" :max="10" @change="priorityChange(row)"
  37. style="width: 80px"></el-input>
  38. <el-popover placement="right" width="200" trigger="hover" content="数值越大优先级越高(0-3普通, 4-6优先, 7-10紧急)">
  39. <div class="sort-wrap" slot="reference">
  40. <i class="el-icon-caret-top" @click="sortTop(row)"></i>
  41. <i class="el-icon-caret-bottom" @click="sortBottom(row)"></i>
  42. </div>
  43. </el-popover>
  44. </div>
  45. </template>
  46. <template v-slot:status="{ row }">
  47. <span :class="{ 'ele-text-danger': row.status == 3 }">
  48. {{ statusFormatter(row.status) }}
  49. </span>
  50. </template>
  51. <!-- 操作列 -->
  52. <template v-slot:action="{ row }">
  53. <el-link type="primary" :underline="false" @click="toUnpack(row)" v-if="
  54. (clientEnvironmentId != '4' && row.status == 8) ||
  55. (clientEnvironmentId == '4' &&
  56. !row.productName.includes('板材') &&
  57. row.status == 8)
  58. ">
  59. 拆单
  60. </el-link>
  61. <el-link type="primary" :underline="false" icon="el-icon-truck" @click="toRelease(row)" v-if="
  62. row.isSplit != 1 &&
  63. (clientEnvironmentId != '4' && row.status == 8) ||
  64. (clientEnvironmentId == '4' &&
  65. !row.productName.includes('板材') &&
  66. row.status == 8)
  67. ">
  68. 派单
  69. </el-link>
  70. <!-- <el-link type="primary" :underline="false" icon="el-icon-truck" @click="toReleaseOpen(row)" v-if="
  71. row.isSplit != 1 &&
  72. (clientEnvironmentId != '4' && row.status == 8) ||
  73. (clientEnvironmentId == '4' &&
  74. !row.productName.includes('板材') &&
  75. row.status == 8)
  76. ">
  77. 派单2
  78. </el-link> -->
  79. </template>
  80. </ele-pro-table>
  81. </el-card>
  82. <el-dialog :visible.sync="visible" title="派单" width="500px">
  83. <el-form ref="form" :model="form" :rules="rules" label-position="left" label-width="100px">
  84. <el-form-item label="报工类型:" prop="singleReport">
  85. <el-radio-group v-model="form.singleReport">
  86. <el-radio :label="1" v-if="clientEnvironmentId != 2">单件报工</el-radio>
  87. <el-radio :label="0">批量报工</el-radio>
  88. </el-radio-group>
  89. </el-form-item>
  90. <el-form-item label="指定:" prop="assignType">
  91. <el-radio-group v-model="form.assignType" size="mini" @change="assignTypeFn">
  92. <el-radio-button :label="1">工位</el-radio-button>
  93. <el-radio-button :label="2">人员</el-radio-button>
  94. </el-radio-group>
  95. </el-form-item>
  96. <el-form-item label="班组:" prop="teamId">
  97. <el-select class="ele-block" v-model="form.teamId" placeholder="请选择班组" size="mini" filterable
  98. @change="stationChange">
  99. <el-option v-for="item in teamsList" :key="item.id" :label="item.name + '(' + item.code + ')'"
  100. :value="item.id">
  101. </el-option>
  102. </el-select>
  103. </el-form-item>
  104. <el-form-item label="工位:" prop="workstationIds" v-if="form.assignType == 1">
  105. <el-select class="ele-block" v-model="form.workstationIds" placeholder="请选择工位" size="mini" multiple
  106. filterable>
  107. <el-option v-for="item in stationList" :key="item.id" :label="item.name + '(' + item.code + ')'"
  108. :value="item.id">
  109. </el-option>
  110. </el-select>
  111. </el-form-item>
  112. <el-form-item label="人员:" prop="crewIds" v-if="form.assignType == 2">
  113. <el-select class="ele-block" v-model="form.crewIds" placeholder="请选择人员" size="mini" filterable multiple>
  114. <el-option v-for="item in crewList" :key="item.id" :label="item.name" :value="item.id">
  115. </el-option>
  116. </el-select>
  117. </el-form-item>
  118. </el-form>
  119. <div class="footer" slot="footer">
  120. <el-button @click="close">取消</el-button>
  121. <el-button type="primary" v-click-once @click="confirm">确定</el-button>
  122. </div>
  123. </el-dialog>
  124. <unpackDialog ref="unpackRef" @success="createSuccess" />
  125. <releaseDialog ref="releaseRef" @success="createSuccess" />
  126. </div>
  127. </template>
  128. <script>
  129. import {
  130. getList,
  131. releaseWorkOrder,
  132. updatePriority
  133. } from '@/api/workOrder/index.js';
  134. import {
  135. teamPage,
  136. listByFirstTaskId,
  137. listByWorkCenterId,
  138. listUserByIds
  139. } from '@/api/mainData/index.js';
  140. import OrderSearch from './components/order-search.vue';
  141. import unpackDialog from './components/unpackDialog.vue';
  142. import releaseDialog from './components/releaseDialog.vue';
  143. import { fieldModel } from '@/api/saleOrder';
  144. import { debounce } from 'lodash';
  145. import PlanStatistics from "@/components/statistics/PlanStatistics.vue";
  146. import tabMixins from '@/mixins/tableColumnsMixin';
  147. export default {
  148. mixins: [tabMixins],
  149. components: {
  150. PlanStatistics,
  151. OrderSearch,
  152. unpackDialog,
  153. releaseDialog
  154. },
  155. data() {
  156. return {
  157. visible: false,
  158. loading: false,
  159. form: {
  160. assignType: 1,
  161. crewIds: '',
  162. workstationIds: '',
  163. teamId: '',
  164. singleReport: ''
  165. },
  166. rules: {
  167. singleReport: [
  168. {
  169. required: true,
  170. message: '请选择报工类型',
  171. trigger: ['blur', 'change']
  172. }
  173. ],
  174. workstationIds: [
  175. {
  176. required: true,
  177. message: '请选择工位',
  178. trigger: ['blur']
  179. }
  180. ],
  181. teamId: [
  182. {
  183. required: true,
  184. message: '请选择班组',
  185. trigger: ['blur']
  186. }
  187. ]
  188. },
  189. teamList: [],
  190. statusOpt: [
  191. { label: '待生产', value: 4 },
  192. { label: '生产中', value: 5 },
  193. { label: '待下达', value: 8 }
  194. ],
  195. newColumns: [],
  196. stationList: [],
  197. teamsList: [],
  198. crewList: [],
  199. current: null,
  200. cacheKeyUrl: '3cbbdff9-aps-workOrder',
  201. columnsVersion:1
  202. };
  203. },
  204. computed: {
  205. teamId() {
  206. return this.$store.state.user.info.teamId;
  207. },
  208. clientEnvironmentId() {
  209. return this.$store.state.user.info.clientEnvironmentId;
  210. },
  211. // 表格列配置
  212. columns() {
  213. const num = this.columnsVersion
  214. return [
  215. {
  216. columnKey: 'index',
  217. slot: 'index',
  218. label: '序号',
  219. type: 'index',
  220. width: 55,
  221. align: 'center',
  222. showOverflowTooltip: true,
  223. fixed: 'left'
  224. },
  225. {
  226. slot: 'code',
  227. label: '生产订单号',
  228. align: 'center',
  229. minWidth: 210,
  230. sortable: true
  231. },
  232. {
  233. prop: 'productionPlanCode',
  234. label: '计划编号',
  235. align: 'center',
  236. minWidth: 150
  237. },
  238. {
  239. prop: 'produceRoutingName',
  240. label: '工艺路线',
  241. align: 'center',
  242. minWidth: 170
  243. },
  244. {
  245. prop: 'productCode',
  246. label: '编码',
  247. align: 'center',
  248. minWidth: 110
  249. },
  250. {
  251. prop: 'productName',
  252. label: '名称',
  253. align: 'center',
  254. minWidth: 170
  255. },
  256. {
  257. prop: 'productionCodes',
  258. label: '生产编号',
  259. align: 'center',
  260. minWidth: 150,
  261. showOverflowTooltip: true
  262. },
  263. {
  264. prop: 'brandNo',
  265. label: '牌号',
  266. align: 'center'
  267. },
  268. {
  269. prop: 'batchNo',
  270. label: '批次号',
  271. align: 'center',
  272. minWidth: 100,
  273. showOverflowTooltip: true
  274. },
  275. {
  276. prop: 'model',
  277. label: '型号',
  278. align: 'center',
  279. showOverflowTooltip: true
  280. },
  281. {
  282. prop: 'priority',
  283. label: '优先级',
  284. align: 'center',
  285. minWidth: 120,
  286. slot: 'priority',
  287. sortable: 'custom'
  288. },
  289. {
  290. prop: 'formingNum',
  291. label: '要求生产数量',
  292. align: 'center',
  293. showOverflowTooltip: true,
  294. minWidth: 110
  295. },
  296. {
  297. prop: 'formingWeight',
  298. label: '要求生产重量',
  299. align: 'center',
  300. showOverflowTooltip: true,
  301. minWidth: 110,
  302. slot: 'formingWeight'
  303. },
  304. {
  305. prop: 'planStartTime',
  306. label: '计划开始时间',
  307. align: 'center',
  308. showOverflowTooltip: true,
  309. minWidth: 110
  310. },
  311. {
  312. prop: 'planCompleteTime',
  313. label: '计划结束时间',
  314. align: 'center',
  315. showOverflowTooltip: true,
  316. minWidth: 110
  317. },
  318. {
  319. prop: 'workCenterName',
  320. label: '工作中心',
  321. align: 'center',
  322. minWidth: 110,
  323. showOverflowTooltip: true
  324. },
  325. {
  326. prop: 'firstTaskName',
  327. label: '首工序',
  328. align: 'center',
  329. minWidth: 110,
  330. showOverflowTooltip: true
  331. },
  332. {
  333. prop: 'createTime',
  334. label: '创建时间',
  335. align: 'center',
  336. showOverflowTooltip: true,
  337. minWidth: 110,
  338. sortable: 'custom'
  339. },
  340. {
  341. slot: 'status',
  342. label: '状态',
  343. align: 'center',
  344. formatter: (row) => {
  345. const obj = this.statusOpt.find((i) => i.value == row.status);
  346. return obj && obj.label;
  347. }
  348. },
  349. {
  350. prop: 'customerName',
  351. label: '客户名称',
  352. align: 'center',
  353. showOverflowTooltip: true
  354. },
  355. {
  356. prop: 'serialNo',
  357. label: '客户代号',
  358. align: 'center',
  359. showOverflowTooltip: true
  360. },
  361. {
  362. prop: 'simpleName',
  363. label: '客户简称',
  364. align: 'center',
  365. showOverflowTooltip: true
  366. }
  367. ];
  368. }
  369. },
  370. created() {
  371. this.getFieldModel();
  372. },
  373. methods: {
  374. assignTypeFn(e) {
  375. },
  376. statusFormatter(status) {
  377. const obj = this.statusOpt.find((i) => i.value == status);
  378. return obj && obj.label;
  379. },
  380. /* 表格数据源 */
  381. datasource({ page, limit, where }) {
  382. if (where.status) {
  383. where.statusList = [];
  384. where.statusList.push(where.status);
  385. }
  386. return getList({
  387. pageNum: page,
  388. size: limit,
  389. ...where,
  390. ...this.sort
  391. });
  392. },
  393. /* 数据转为树形结构 */
  394. parseData(data) {
  395. return {
  396. ...data,
  397. list: this.$util.toTreeData({
  398. data: data.list,
  399. count: data.total,
  400. idField: 'code',
  401. parentIdField: 'originalCode'
  402. })
  403. };
  404. },
  405. getFieldModel() {
  406. fieldModel({ fieldModel: 't_main_category' }).then((res) => {
  407. const privateColumn = [
  408. {
  409. columnKey: 'action',
  410. label: '操作',
  411. width: 120,
  412. align: 'center',
  413. resizable: false,
  414. fixed: 'right',
  415. slot: 'action'
  416. }
  417. ];
  418. let newRes = res.map((m) => {
  419. return {
  420. prop: 'extField.' + m.prop,
  421. label: m.label,
  422. align: 'center',
  423. showOverflowTooltip: true
  424. };
  425. });
  426. this.newColumns = [...this.columns, ...newRes, ...privateColumn];
  427. this.$forceUpdate();
  428. });
  429. },
  430. // 下达
  431. toRelease(row) {
  432. this.current = row;
  433. this.visible = true;
  434. this.FirstTaskIdFn();
  435. this.WorkCenterIdFn();
  436. this.form.singleReport = this.clientEnvironmentId == 2 ? 0 : 1
  437. },
  438. // 下达
  439. confirm() {
  440. this.$refs.form.validate((valid)=>{
  441. if (valid) {
  442. const loading = this.$loading({ text: '加载中...' });
  443. if (this.form.assignType * 1 == 2) {
  444. this.form.workstationIds = [];
  445. } else {
  446. this.form.crewIds = [];
  447. }
  448. releaseWorkOrder({
  449. id: this.current.id,
  450. ...this.form
  451. })
  452. .then((res) => {
  453. if (res) {
  454. this.$message.success('成功');
  455. this.reData();
  456. this.reload();
  457. this.visible = false;
  458. }
  459. })
  460. .finally(() => {
  461. loading.close();
  462. });
  463. }
  464. })
  465. },
  466. close() {
  467. this.visible = false;
  468. this.reData();
  469. },
  470. reData() {
  471. this.form = {
  472. assignType: 1,
  473. crewIds: '',
  474. workstationIds: '',
  475. teamId: '',
  476. singleReport: this.clientEnvironmentId == 2 ? 0 : 1
  477. };
  478. },
  479. /* 刷新表格 */
  480. reload(where) {
  481. this.$nextTick(() => {
  482. this.$refs.table.reload({ page: 1, where });
  483. });
  484. },
  485. onSortChange(e) {
  486. let sort = {
  487. orderBy: e.order,
  488. sortName: e.prop
  489. };
  490. this.sort = sort;
  491. this.reload();
  492. },
  493. sortTop(row) {
  494. row.priority = Number(row.priority) + 1;
  495. this.priorityChange(row);
  496. },
  497. sortBottom(row) {
  498. if (row.priority <= 1) {
  499. return;
  500. }
  501. row.priority = Number(row.priority) - 1;
  502. this.priorityChange(row);
  503. },
  504. FirstTaskIdFn() {
  505. listByFirstTaskId(this.current.firstTaskId).then((res) => {
  506. this.stationList = res;
  507. });
  508. },
  509. WorkCenterIdFn() {
  510. listByWorkCenterId(this.current.workCenterId).then((res) => {
  511. this.teamsList = res;
  512. this.$nextTick(() => {
  513. if (this.teamId) {
  514. this.$set(this.form, 'teamId', this.teamId);
  515. this.stationChange();
  516. }
  517. // this.$refs.form.clearValidate();
  518. })
  519. });
  520. },
  521. // 拆分
  522. toUnpack(row) {
  523. this.$refs.unpackRef.open(row);
  524. },
  525. //派单
  526. toReleaseOpen(row){
  527. this.$refs.releaseRef.open(row);
  528. },
  529. createSuccess() {
  530. this.reload();
  531. },
  532. stationChange() {
  533. this.crewList = [];
  534. this.crewIds = [];
  535. listUserByIds([this.form.teamId]).then((res) => {
  536. this.crewList = res;
  537. });
  538. },
  539. priorityChange(row) {
  540. if (row.priority > 10) {
  541. row.priority = 10; // 如果大于 10,则设置为 10
  542. } else if (row.priority < 0) {
  543. row.priority = 0; // 如果小于 0,则设置为 0
  544. }
  545. this.priorityFn(row);
  546. },
  547. priorityFn: debounce(function (row) {
  548. let params = {
  549. id: row.id,
  550. priority: row.priority
  551. };
  552. updatePriority(params).then((res) => { });
  553. }, 800)
  554. }
  555. };
  556. </script>
  557. <style lang="scss" scoped>
  558. // ::v-deep .el-table__row {
  559. // height: 51px !important;
  560. // }</style>