list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. <template>
  2. <div>
  3. <FullPage
  4. title="生产计划列表"
  5. :list="set_list"
  6. @init="init"
  7. @searchData="searchData"
  8. @selectTable="selectTable"
  9. @changePage="changePage"
  10. @changeSize="changeSize"
  11. :tableColums="computedTable"
  12. :tableData="tableData"
  13. :showPage="false"
  14. :page_index="page_index"
  15. :total="total"
  16. >
  17. <div slot="titleButton">
  18. <Button
  19. v-if="persimissionData['分类派工'] || persimissionData.all"
  20. type="primary"
  21. style="margin-right:10px"
  22. @click="handleDispatchType(selects)"
  23. ghost
  24. >分类派工</Button
  25. >
  26. <Button
  27. v-if="persimissionData['批量派工单'] || persimissionData.all"
  28. type="primary"
  29. @click="dispatchList(selects)"
  30. ghost
  31. >批量派工单</Button
  32. >
  33. </div>
  34. <div slot="navButton">
  35. <Button
  36. v-if="persimissionData['表头设置'] || persimissionData.all"
  37. @click="setupTableHeader"
  38. type="primary"
  39. ghost
  40. icon="ios-cog"
  41. >表头设置</Button
  42. >
  43. </div>
  44. <template slot="basicTypeSet" slot-scope="{ row }">
  45. <div>
  46. <span
  47. v-for="item in warningList"
  48. :key="item.id"
  49. :style="{ color: item.color }"
  50. v-show="item.id == row.warning_state"
  51. >{{ item.title }}</span
  52. >
  53. </div>
  54. </template>
  55. <template slot="set" slot-scope="{ row }">
  56. <div>
  57. <a
  58. v-if="persimissionData['详情'] || persimissionData.all"
  59. style="margin:0 5px"
  60. @click="goDetial(row)"
  61. >详情</a
  62. >
  63. <a
  64. v-if="persimissionData['派工单'] || persimissionData.all"
  65. style="margin:0 5px"
  66. @click="dispatchList(row)"
  67. >派工单</a
  68. >
  69. </div>
  70. </template>
  71. <div>
  72. <Modal
  73. :width="1064"
  74. class-name="vertical-center-modal"
  75. v-model="showTableColums"
  76. title="设置表头"
  77. >
  78. <Form>
  79. <FormItem label="订单信息:">
  80. <div style="width:100%;display:flex;">
  81. <CheckboxGroup style="width:100%">
  82. <Checkbox label="香蕉"></Checkbox>
  83. <Checkbox label="苹果"></Checkbox>
  84. <Checkbox label="西瓜"></Checkbox>
  85. <Checkbox label="香蕉"></Checkbox>
  86. </CheckboxGroup>
  87. </div>
  88. </FormItem>
  89. </Form>
  90. </Modal>
  91. </div>
  92. <template slot="pageSlot">
  93. <div class="pageSlotStyle">
  94. <Page
  95. :page-size-opts="[10, 20, 30, 40, 100, 1000]"
  96. @on-page-size-change="changeSize"
  97. @on-change="changePage"
  98. :current="page_index"
  99. show-total
  100. :total="total"
  101. show-sizer
  102. :page-size="page_size"
  103. />
  104. </div>
  105. </template>
  106. </FullPage>
  107. </div>
  108. </template>
  109. <script>
  110. import { mapState } from "vuex";
  111. export default {
  112. data() {
  113. return {
  114. tableColums: [
  115. {
  116. type: "selection",
  117. title: "全选",
  118. key: "selection",
  119. fixed: "left",
  120. width: "90",
  121. align: "center",
  122. },
  123. { title: "订单编号", align: "center", key: "order_no", minWidth: 200 },
  124. { title: "计划单号", align: "center", key: "plan_no", minWidth: 200 },
  125. {
  126. title: "订单类型",
  127. align: "center",
  128. key: "order_type",
  129. minWidth: 150,
  130. render(h, params) {
  131. return h("span", {}, params.row.order_type == 1 ? "工装" : "家装");
  132. },
  133. },
  134. {
  135. title: "订单状态",
  136. align: "center",
  137. key: "state",
  138. minWidth: 150,
  139. render: (h, params) =>
  140. h(
  141. "span",
  142. {},
  143. params.row.state == 0
  144. ? "未派工"
  145. : params.row.state == 1
  146. ? "已派工"
  147. : params.row.state == 2
  148. ? "完成"
  149. : ""
  150. ),
  151. },
  152. { title: "业务员", align: "center", key: "nickname", minWidth: 150 },
  153. {
  154. title: "紧急程度",
  155. align: "center",
  156. key: "warning_state",
  157. minWidth: 150,
  158. slot: "basicTypeSet",
  159. },
  160. {
  161. title: "项目名称",
  162. align: "center",
  163. key: "residential_name",
  164. minWidth: 200,
  165. },
  166. {
  167. title: "计划开始时间",
  168. align: "center",
  169. minWidth: 200,
  170. key: "plan_start_time",
  171. render: (h, params) =>
  172. h("span", {}, this.func.replaceDate(params.row.plan_start_time, 1)),
  173. },
  174. {
  175. title: "计划结束时间",
  176. align: "center",
  177. minWidth: 200,
  178. key: "plan_end_time",
  179. render: (h, params) =>
  180. h("span", {}, this.func.replaceDate(params.row.plan_end_time, 1)),
  181. },
  182. {
  183. title: "生产进度",
  184. align: "center",
  185. key: "complete_rate",
  186. minWidth: 100,
  187. render: (h, params) =>
  188. h("span", {}, parseInt(params.row.complete_rate * 100) + "%"),
  189. },
  190. {
  191. title: "预估交付日期",
  192. align: "center",
  193. key: "predict_time",
  194. minWidth: 200,
  195. render: (h, params) =>
  196. h("span", {}, this.func.replaceDate(params.row.predict_time, 1)),
  197. },
  198. {
  199. title: "操作",
  200. align: "center",
  201. key: "set",
  202. slot: "set",
  203. fixed: "right",
  204. width: "150",
  205. },
  206. ],
  207. tableData: [],
  208. page_index: 1,
  209. page_size: 10,
  210. total: 0,
  211. proxyObj: {},
  212. showTableColums: false,
  213. selects: [],
  214. tableheaders: [],
  215. userList: [],
  216. //详情页返回保留搜索数据
  217. corssPageData: localStorage.getItem("corssPageData")
  218. ? JSON.parse(localStorage.getItem("corssPageData"))
  219. : {},
  220. warningList: [],
  221. };
  222. },
  223. beforeRouteEnter(to, from, next) {
  224. next((vm) => {
  225. if (from.path != "/cms/productionorderlist/productionplanlist/details") {
  226. localStorage.removeItem("corssPageData");
  227. } else {
  228. vm.firstEnter = 1;
  229. }
  230. });
  231. },
  232. beforeRouteLeave(to, from, next) {
  233. if (to.path == "/cms/productionorderlist/productionplanlist/details") {
  234. (this.corssPageData.page_index = this.page_index),
  235. (this.corssPageData.page_size = this.page_size),
  236. localStorage.setItem(
  237. "corssPageData",
  238. JSON.stringify(this.corssPageData)
  239. );
  240. } else {
  241. localStorage.removeItem("corssPageData");
  242. }
  243. next((vm) => {});
  244. },
  245. created() {
  246. // 获取紧急程度
  247. this.axios.get("/api/warning_list").then((res) => {
  248. this.warningList = res.data.data;
  249. });
  250. this.axios
  251. .get("/api/employee_list")
  252. .then((res) => (this.userList = res.data));
  253. //this.axios.get('/api/employee_list').then(res => { this.employeeList = res.data })
  254. },
  255. computed: {
  256. ...mapState(["persimissionData"]),
  257. computedTable() {
  258. // if (this.tableheaders.length < 1) {
  259. return this.tableColums;
  260. // }
  261. // return this.func.computedHeader(this.tableheaders, this.tableColums)
  262. },
  263. set_list() {
  264. return [
  265. {
  266. title: "订单编号",
  267. name: "Input",
  268. serverName: "order_no",
  269. placeholder: "请输入订单编号",
  270. value: "",
  271. },
  272. {
  273. title: "项目名称",
  274. name: "Input",
  275. serverName: "residential_name",
  276. placeholder: "请选择项目名称",
  277. value: "",
  278. },
  279. {
  280. title: "订单类型",
  281. name: "Select",
  282. placeholder: "请选择",
  283. serverName: "order_type",
  284. value: "",
  285. option: [
  286. { label: "工装", value: 1 },
  287. { label: "家装", value: 0 },
  288. ],
  289. },
  290. {
  291. title: "计划单号",
  292. name: "Input",
  293. serverName: "plan_no",
  294. placeholder: "请填写计划单号",
  295. value: "",
  296. },
  297. {
  298. title: "业务员",
  299. name: "Select",
  300. serverName: "nickname",
  301. placeholder: "请选择",
  302. value: "",
  303. optionName: "nickname",
  304. optionValue: "id",
  305. option: this.userList,
  306. },
  307. {
  308. title: "计划开始时间",
  309. name: "Input",
  310. start_server: "start_time",
  311. end_server: "end_time",
  312. start_value: "",
  313. end_value: "",
  314. isDate: true,
  315. serverName: "id2",
  316. start_placeholder: "开始日期",
  317. end_placeholder: "结束日期",
  318. },
  319. {
  320. title: "紧急程度",
  321. name: "Select",
  322. serverName: "warning_state",
  323. placeholder: "请选择",
  324. value: "",
  325. optionName: "title",
  326. optionValue: "id",
  327. option: this.warningList,
  328. },
  329. {
  330. title: "订单状态",
  331. name: "Select",
  332. placeholder: "请选择",
  333. serverName: "state",
  334. value: "",
  335. option: [
  336. { label: "未派工", value: 0 },
  337. { label: "已派工", value: 1 },
  338. { label: "完成", value: 2 },
  339. ],
  340. },
  341. ];
  342. },
  343. },
  344. methods: {
  345. init(row) {
  346. const { order_no } = this.$route.query;
  347. if (order_no) {
  348. row.order_no = order_no;
  349. this.set_list[0].value = order_no;
  350. }
  351. row.sub_state = 5;
  352. if (this.firstEnter == 1) {
  353. this.corssPageData = JSON.parse(localStorage.getItem("corssPageData"));
  354. row = this.corssPageData;
  355. this.proxyObj = row;
  356. this.searchData(row);
  357. } else {
  358. this.page_index = 1;
  359. row.page_index = this.page_index;
  360. row.page_size = this.page_size;
  361. this.proxyObj = row;
  362. this.getData(row);
  363. }
  364. },
  365. searchData(row) {
  366. if (this.firstEnter == 1) {
  367. this.page_index = this.corssPageData.page_index;
  368. this.page_size = this.corssPageData.page_size;
  369. this.set_list[0].value = this.corssPageData.order_no;
  370. this.set_list[1].value = this.corssPageData.residential_name;
  371. this.set_list[3].value = this.corssPageData.warning_state;
  372. this.set_list[4].value = this.corssPageData.state;
  373. this.set_list[2].start_value = this.corssPageData.start_time
  374. ? this.corssPageData.start_time
  375. : "";
  376. this.set_list[2].end_value = this.corssPageData.end_time
  377. ? this.corssPageData.end_time
  378. : "";
  379. this.corssPageData.type = this.$route.query.type;
  380. this.getData(this.corssPageData);
  381. } else {
  382. this.page_index = 1;
  383. row.page_index = this.page_index;
  384. row.page_size = this.page_size;
  385. this.corssPageData.order_no = this.set_list[0].value;
  386. this.corssPageData.residential_name = this.set_list[1].value;
  387. this.corssPageData.warning_state = this.set_list[3].value;
  388. this.corssPageData.state = this.set_list[4].value;
  389. this.corssPageData.start_time = this.func.setDate(
  390. this.set_list[2].start_value
  391. );
  392. this.corssPageData.end_time = this.func.setDate(
  393. this.set_list[2].end_value
  394. );
  395. this.proxyObj = row;
  396. this.getData(row);
  397. }
  398. },
  399. changePage(e) {
  400. this.page_index = e;
  401. this.proxyObj.page_index = this.page_index;
  402. this.proxyObj.page_size = this.page_size;
  403. this.getData(this.proxyObj);
  404. },
  405. changeSize(e) {
  406. this.page_size = e;
  407. this.proxyObj.page_size = this.page_size;
  408. this.getData(this.proxyObj);
  409. },
  410. getData(row) {
  411. this.axios("/api/orders_produce_plan_list", { params: row }).then(
  412. (res) => {
  413. this.firstEnter++;
  414. this.tableData = res.data.data;
  415. this.total = res.data.total;
  416. // this.tableheaders = res.data.tableSet || []
  417. }
  418. );
  419. },
  420. setTableColums() {
  421. //设置表头
  422. this.showTableColums = true;
  423. },
  424. goDetial(row) {
  425. this.$router.push({
  426. path: "/cms/productionorderlist/productionplanlist/details",
  427. query: {
  428. order_no: row.order_no,
  429. plan_no: row.plan_no,
  430. },
  431. });
  432. },
  433. handleDispatchType(row) {
  434. console.log("row :>> ", row);
  435. this.$router.push({
  436. path: "/cms/Dispatching/Dispatching",
  437. query: {
  438. order_no: row.order_no,
  439. plan_no: row.plan_no,
  440. },
  441. });
  442. },
  443. dispatchList(row) {
  444. this.dispatchOrder({
  445. params: {
  446. order_no: Array.isArray(row) ? this.selects.join(",") : row.order_no,
  447. },
  448. then: () => this.getData(this.proxyObj),
  449. });
  450. },
  451. selectTable(e) {
  452. let result = [];
  453. e.map((v) => result.push(v.order_no));
  454. this.selects = result;
  455. },
  456. setupTableHeader() {
  457. this.tableheaders.length < 1
  458. ? (this.tableheaders = this.tableColums.reduce(
  459. (pre, cur) => pre.concat(cur.key),
  460. []
  461. ))
  462. : "";
  463. this.$setTableheader({
  464. list: this.tableColums,
  465. selects: this.tableheaders,
  466. then: (result) => {
  467. this.tableheaders = result;
  468. this.axios
  469. .post("/api/update/table", { id: this.$route.query.id, result })
  470. .then((res) => {
  471. if (res.code == 200) {
  472. this.$Message.success(res.msg);
  473. }
  474. });
  475. },
  476. });
  477. },
  478. },
  479. };
  480. </script>
  481. <style lang="scss" scoped>
  482. .pageSlotStyle {
  483. display: flex;
  484. justify-content: center;
  485. margin-top: 40px;
  486. }
  487. </style>