index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  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. @sort-change="onSortChange"
  16. height="calc(100vh - 380px)"
  17. >
  18. <template v-slot:code="{ row }">
  19. {{ row.code }}
  20. </template>
  21. <template v-slot:formingWeight="{ row }">
  22. {{ row.formingWeight }} {{ row.newWeightUnit }}
  23. </template>
  24. <template v-slot:priority="{ row }">
  25. <div style="display: flex">
  26. <el-input
  27. v-model="row.priority"
  28. type="number"
  29. size="mini"
  30. :min="0"
  31. :max="10"
  32. @change="priorityChange(row)"
  33. style="width: 80px"
  34. ></el-input>
  35. <el-popover
  36. placement="right"
  37. width="200"
  38. trigger="hover"
  39. content="数值越大优先级越高(0-3普通, 4-6优先, 7-10紧急)"
  40. >
  41. <div class="sort-wrap" slot="reference">
  42. <i class="el-icon-caret-top" @click="sortTop(row)"></i>
  43. <i class="el-icon-caret-bottom" @click="sortBottom(row)"></i>
  44. </div>
  45. </el-popover>
  46. </div>
  47. </template>
  48. <template v-slot:status="{ row }">
  49. <span :class="{ 'ele-text-danger': row.status == 3 }">
  50. {{ statusFormatter(row.status) }}
  51. </span>
  52. </template>
  53. <!-- 操作列 -->
  54. <template v-slot:action="{ row }">
  55. <el-link
  56. type="primary"
  57. :underline="false"
  58. icon="el-icon-truck"
  59. @click="toRelease(row)"
  60. v-if="
  61. (clientEnvironmentId != '4' && row.status == 8) ||
  62. (clientEnvironmentId == '4' &&
  63. !row.productName.includes('板材') &&
  64. row.status == 8)
  65. "
  66. >
  67. 派单
  68. </el-link>
  69. </template>
  70. </ele-pro-table>
  71. </el-card>
  72. <el-dialog :visible.sync="visible" title="派单" width="500px">
  73. <el-form ref="form" :model="form" :rules="rules" label-position="left" label-width="100px" >
  74. <el-form-item label="指定:" prop="singleType">
  75. <el-radio-group
  76. v-model="singleType"
  77. size="mini"
  78. >
  79. <el-radio-button :label="1">工位</el-radio-button>
  80. <el-radio-button :label="2">人员</el-radio-button>
  81. </el-radio-group>
  82. </el-form-item>
  83. <el-form-item label="报工类型:" prop="singleReport">
  84. <el-radio-group v-model="form.singleReport">
  85. <el-radio :label="1">单件报工</el-radio>
  86. <el-radio :label="0">批量报工</el-radio>
  87. </el-radio-group>
  88. </el-form-item>
  89. </el-form>
  90. <div class="footer" slot="footer">
  91. <el-button @click="visible = false">取消</el-button>
  92. <el-button type="primary" v-click-once @click="confirm">确定</el-button>
  93. </div>
  94. </el-dialog>
  95. </div>
  96. </template>
  97. <script>
  98. import {
  99. getList,
  100. releaseWorkOrder,
  101. updatePriority
  102. } from '@/api/workOrder/index.js';
  103. import { teamPage } from '@/api/mainData/index.js';
  104. import OrderSearch from './components/order-search.vue';
  105. import { fieldModel } from '@/api/saleOrder';
  106. import { debounce } from 'lodash';
  107. export default {
  108. components: {
  109. OrderSearch
  110. },
  111. data() {
  112. return {
  113. visible: false,
  114. loading: false,
  115. singleType: 1,
  116. form: {
  117. singleReport: 1
  118. },
  119. rules: {},
  120. teamList: [],
  121. statusOpt: [
  122. { label: '待生产', value: 4 },
  123. { label: '生产中', value: 5 },
  124. { label: '待下达', value: 8 }
  125. ],
  126. newColumns: [],
  127. current: null
  128. };
  129. },
  130. computed: {
  131. clientEnvironmentId() {
  132. return this.$store.state.user.info.clientEnvironmentId;
  133. },
  134. // 表格列配置
  135. columns() {
  136. return [
  137. {
  138. columnKey: 'index',
  139. label: '序号',
  140. type: 'index',
  141. width: 55,
  142. align: 'center',
  143. showOverflowTooltip: true,
  144. fixed: 'left'
  145. },
  146. {
  147. slot: 'code',
  148. label: '生产订单号',
  149. align: 'center',
  150. minWidth: 110,
  151. sortable: true
  152. },
  153. {
  154. prop: 'productionPlanCode',
  155. label: '计划编号',
  156. align: 'center',
  157. minWidth: 110,
  158. },
  159. {
  160. prop: 'produceRoutingName',
  161. label: '工艺路线',
  162. align: 'center',
  163. minWidth: 110,
  164. },
  165. {
  166. prop: 'productCode',
  167. label: '产品编码',
  168. align: 'center',
  169. minWidth: 110,
  170. },
  171. {
  172. prop: 'productName',
  173. label: '产品名称',
  174. align: 'center',
  175. minWidth: 110,
  176. },
  177. {
  178. prop: 'brandNo',
  179. label: '牌号',
  180. align: 'center'
  181. },
  182. {
  183. prop: 'batchNo',
  184. label: '批次号',
  185. align: 'center',
  186. minWidth: 100,
  187. showOverflowTooltip: true
  188. },
  189. {
  190. prop: 'model',
  191. label: '型号',
  192. align: 'center'
  193. },
  194. {
  195. prop: '',
  196. label: '工作中心',
  197. align: 'center'
  198. },
  199. {
  200. prop: '',
  201. label: '首工序',
  202. align: 'center'
  203. },
  204. {
  205. prop: 'priority',
  206. label: '优先级',
  207. align: 'center',
  208. minWidth: 120,
  209. slot: 'priority',
  210. sortable: 'custom'
  211. },
  212. {
  213. prop: 'formingNum',
  214. label: '要求生产数量',
  215. align: 'center',
  216. showOverflowTooltip: true,
  217. minWidth: 110
  218. },
  219. {
  220. prop: 'formingWeight',
  221. label: '要求生产重量',
  222. align: 'center',
  223. showOverflowTooltip: true,
  224. minWidth: 110,
  225. slot: 'formingWeight'
  226. },
  227. {
  228. prop: 'planStartTime',
  229. label: '计划开始时间',
  230. align: 'center',
  231. showOverflowTooltip: true,
  232. minWidth: 110
  233. },
  234. {
  235. prop: 'planCompleteTime',
  236. label: '计划结束时间',
  237. align: 'center',
  238. showOverflowTooltip: true,
  239. minWidth: 110
  240. },
  241. {
  242. prop: 'createTime',
  243. label: '创建时间',
  244. align: 'center',
  245. showOverflowTooltip: true,
  246. minWidth: 110,
  247. sortable: 'custom'
  248. },
  249. {
  250. slot: 'status',
  251. label: '状态',
  252. align: 'center',
  253. formatter: (row) => {
  254. const obj = this.statusOpt.find((i) => i.value == row.status);
  255. return obj && obj.label;
  256. }
  257. },
  258. {
  259. prop: 'serialNo',
  260. label: '客户代号',
  261. align: 'center',
  262. showOverflowTooltip: true
  263. },
  264. {
  265. prop: 'simpleName',
  266. label: '客户简称',
  267. align: 'center',
  268. showOverflowTooltip: true
  269. }
  270. ];
  271. }
  272. },
  273. created() {
  274. this.getFieldModel();
  275. },
  276. methods: {
  277. statusFormatter(status) {
  278. const obj = this.statusOpt.find((i) => i.value == status);
  279. return obj && obj.label;
  280. },
  281. /* 表格数据源 */
  282. datasource({ page, limit, where }) {
  283. if (where.status) {
  284. where.statusList = [];
  285. where.statusList.push(where.status);
  286. }
  287. return getList({
  288. pageNum: page,
  289. size: limit,
  290. ...where,
  291. ...this.sort
  292. });
  293. },
  294. getFieldModel() {
  295. fieldModel({ fieldModel: 't_main_category' }).then((res) => {
  296. const privateColumn = [
  297. {
  298. columnKey: 'action',
  299. label: '操作',
  300. width: 90,
  301. align: 'center',
  302. resizable: false,
  303. fixed: 'right',
  304. slot: 'action',
  305. showOverflowTooltip: true
  306. }
  307. ];
  308. let newRes = res.map((m) => {
  309. return {
  310. prop: 'extField.' + m.prop,
  311. label: m.label,
  312. align: 'center',
  313. showOverflowTooltip: true
  314. };
  315. });
  316. this.newColumns = [...this.columns, ...newRes, ...privateColumn];
  317. this.$forceUpdate();
  318. });
  319. },
  320. // 下达
  321. toRelease(row) {
  322. this.current = row;
  323. this.visible = true;
  324. },
  325. // 下达
  326. confirm() {
  327. console.log(111)
  328. return false;
  329. const loading = this.$loading({ text: '加载中...' });
  330. releaseWorkOrder({
  331. id: this.current.id,
  332. singleReport: this.singleReport
  333. })
  334. .then((res) => {
  335. if (res) {
  336. this.$message.success('成功');
  337. this.reload();
  338. this.visible = false;
  339. }
  340. })
  341. .finally(() => {
  342. loading.close();
  343. });
  344. },
  345. /* 刷新表格 */
  346. reload(where) {
  347. this.$nextTick(() => {
  348. this.$refs.table.reload({ page: 1, where });
  349. });
  350. },
  351. onSortChange(e) {
  352. let sort = {
  353. orderBy: e.order,
  354. sortName: e.prop
  355. };
  356. this.sort = sort;
  357. this.reload();
  358. },
  359. sortTop(row) {
  360. row.priority = Number(row.priority) + 1;
  361. this.priorityChange(row);
  362. },
  363. sortBottom(row) {
  364. if (row.priority <= 1) {
  365. return;
  366. }
  367. row.priority = Number(row.priority) - 1;
  368. this.priorityChange(row);
  369. },
  370. priorityChange(row) {
  371. if (row.priority > 10) {
  372. row.priority = 10; // 如果大于 10,则设置为 10
  373. } else if (row.priority < 0) {
  374. row.priority = 0; // 如果小于 0,则设置为 0
  375. }
  376. this.priorityFn(row);
  377. },
  378. priorityFn: debounce(function (row) {
  379. let params = {
  380. id: row.id,
  381. priority: row.priority
  382. };
  383. updatePriority(params).then((res) => {});
  384. }, 800)
  385. }
  386. };
  387. </script>
  388. <style lang="scss" scoped></style>