index.vue 16 KB

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