index.vue 15 KB

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