BST_two.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772
  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. <template slot="pageSlot">
  72. <div class="pageSlotStyle">
  73. <Page
  74. :page-size-opts="[10, 20, 30, 40, 100, 1000]"
  75. @on-page-size-change="changeSize"
  76. @on-change="changePage"
  77. :current="page_index"
  78. show-total
  79. :total="total"
  80. show-sizer
  81. :page-size="page_size"
  82. />
  83. </div>
  84. </template>
  85. </FullPage>
  86. <Modal
  87. v-model="showModal"
  88. title="设置"
  89. @on-ok="handleModalOk"
  90. @on-cancel="showModal = false"
  91. >
  92. <div class="modal_content">
  93. <Tabs
  94. value="name1"
  95. style="max-height: 700px; overflow: hidden; overflow-y: auto"
  96. >
  97. <TabPane label="表单设置" name="name1">
  98. <Table
  99. :columns="formModalColumns"
  100. border
  101. draggable
  102. @on-drag-drop="(a, b) => onDragDrop(a, b, formModalTableData, 1)"
  103. :data="formModalTableData"
  104. ></Table>
  105. </TabPane>
  106. <TabPane label="表头设置" name="name2">
  107. <Table
  108. :columns="tableModalColumns"
  109. border
  110. draggable
  111. @on-drag-drop="(a, b) => onDragDrop(a, b, tableModalTableData, 2)"
  112. :data="tableModalTableData"
  113. ></Table>
  114. </TabPane>
  115. </Tabs>
  116. </div>
  117. </Modal>
  118. </div>
  119. </template>
  120. <script>
  121. import { mapState } from "vuex";
  122. export default {
  123. data() {
  124. return {
  125. tableModalColumns: [
  126. {
  127. title: "是否展示",
  128. align: "center",
  129. key: "is_show",
  130. minWidth: 60,
  131. render: (h, params) => {
  132. const { index } = params;
  133. const currentRow = JSON.parse(
  134. JSON.stringify(this.tableModalTableData[index])
  135. );
  136. return h("Checkbox", {
  137. props: {
  138. value: currentRow.is_show,
  139. },
  140. on: {
  141. "on-change": (e) => {
  142. currentRow.is_show = e;
  143. this.tableModalTableData.splice(index, 1, currentRow);
  144. },
  145. },
  146. });
  147. },
  148. },
  149. {
  150. title: "字段名",
  151. align: "center",
  152. key: "value",
  153. minWidth: 100,
  154. },
  155. {
  156. title: "展示名称",
  157. align: "center",
  158. key: "title",
  159. minWidth: 100,
  160. render: (h, params) => {
  161. const { index } = params;
  162. const currentRow = JSON.parse(
  163. JSON.stringify(this.tableModalTableData[index])
  164. );
  165. return h("Input", {
  166. props: {
  167. value: currentRow.title,
  168. type: "text",
  169. disabled: currentRow.title == "全选" ? true : false,
  170. },
  171. on: {
  172. "on-change": (e) => {
  173. currentRow.title = e.target.value;
  174. this.tableModalTableData.splice(index, 1, currentRow);
  175. },
  176. },
  177. });
  178. },
  179. },
  180. ],
  181. tableModalTableData: [
  182. { is_show: true, key: "selection", value: "全选", title: "全选" },
  183. {
  184. is_show: true,
  185. key: "order_no",
  186. value: "订单编号",
  187. title: "订单编号",
  188. },
  189. {
  190. is_show: true,
  191. key: "residential_name",
  192. value: "项目名称",
  193. title: "项目名称",
  194. },
  195. { is_show: true, key: "nickname", value: "业务员", title: "业务员" },
  196. {
  197. is_show: true,
  198. key: "client_name",
  199. value: "客户姓名",
  200. title: "客户姓名",
  201. },
  202. { is_show: true, key: "address", value: "客户地址", title: "客户地址" },
  203. {
  204. is_show: true,
  205. key: "leading_name",
  206. value: "负责人",
  207. title: "负责人",
  208. },
  209. {
  210. is_show: true,
  211. key: "warning_state",
  212. value: "紧急程度",
  213. title: "紧急程度",
  214. },
  215. {
  216. is_show: true,
  217. key: "predict_price",
  218. value: "产品总价",
  219. title: "产品总价",
  220. },
  221. {
  222. is_show: true,
  223. key: "fax_price",
  224. value: "折扣金额",
  225. title: "折扣金额",
  226. },
  227. { is_show: true, key: "price", value: "订单金额", title: "订单金额" },
  228. { is_show: true, key: "get_money", value: "已收款", title: "已收款" },
  229. { is_show: true, key: "unget_money", value: "未收款", title: "未收款" },
  230. { is_show: true, key: "remark", value: "备注", title: "备注" },
  231. {
  232. is_show: true,
  233. key: "start_time",
  234. value: "订单开始日期",
  235. title: "订单开始日期",
  236. },
  237. {
  238. is_show: true,
  239. key: "end_time",
  240. value: "订单交付日期",
  241. title: "订单交付日期",
  242. },
  243. {
  244. is_show: true,
  245. key: "complete_rate",
  246. value: "生产进度",
  247. title: "生产进度",
  248. },
  249. { is_show: true, key: "state", value: "订单状态", title: "订单状态" },
  250. { is_show: true, key: "crt_name", value: "制单人", title: "制单人" },
  251. {
  252. is_show: true,
  253. key: "crt_time",
  254. value: "订单创建时间",
  255. title: "订单创建时间",
  256. },
  257. { is_show: true, key: "set", value: "操作", title: "操作" },
  258. ],
  259. formModalColumns: [
  260. {
  261. title: "是否展示",
  262. align: "center",
  263. key: "is_show",
  264. minWidth: 60,
  265. render: (h, params) => {
  266. const { index } = params;
  267. const currentRow = JSON.parse(
  268. JSON.stringify(this.formModalTableData[index])
  269. );
  270. return h("Checkbox", {
  271. props: {
  272. value: currentRow.is_show,
  273. },
  274. on: {
  275. "on-change": (e) => {
  276. currentRow.is_show = e;
  277. this.formModalTableData.splice(index, 1, currentRow);
  278. },
  279. },
  280. });
  281. },
  282. },
  283. {
  284. title: "字段名",
  285. align: "center",
  286. key: "value",
  287. minWidth: 100,
  288. },
  289. {
  290. title: "展示名称",
  291. align: "center",
  292. key: "title",
  293. minWidth: 100,
  294. render: (h, params) => {
  295. const { index } = params;
  296. const currentRow = JSON.parse(
  297. JSON.stringify(this.formModalTableData[index])
  298. );
  299. return h("Input", {
  300. props: {
  301. value: currentRow.title,
  302. type: "text",
  303. },
  304. on: {
  305. "on-change": (e) => {
  306. currentRow.title = e.target.value;
  307. this.formModalTableData.splice(index, 1, currentRow);
  308. },
  309. },
  310. });
  311. },
  312. },
  313. ],
  314. formModalTableData: [
  315. {
  316. is_show: true,
  317. key: "order_no",
  318. value: "订单编号",
  319. title: "订单编号",
  320. },
  321. {
  322. is_show: true,
  323. key: "residential_name",
  324. value: "项目名称",
  325. title: "项目名称",
  326. },
  327. {
  328. is_show: true,
  329. key: "client_name",
  330. value: "客户姓名",
  331. title: "客户姓名",
  332. },
  333. { is_show: true, key: "address", value: "客户地址", title: "客户地址" },
  334. { is_show: true, key: "salesman", value: "业务员", title: "业务员" },
  335. { is_show: true, key: "state", value: "订单状态", title: "订单状态" },
  336. { is_show: true, key: "crt_id", value: "制单人", title: "制单人" },
  337. {
  338. is_show: true,
  339. key: "leading_name",
  340. value: "负责人",
  341. title: "负责人",
  342. },
  343. {
  344. is_show: true,
  345. key: "warning_state",
  346. value: "紧急程度",
  347. title: "紧急程度",
  348. },
  349. {
  350. is_show: true,
  351. key: "",
  352. value: "订单创建时间",
  353. title: "订单创建时间",
  354. },
  355. ],
  356. tableColums: [
  357. {
  358. type: "selection",
  359. title: "全选",
  360. key: "selection",
  361. fixed: "left",
  362. width: "90",
  363. align: "center",
  364. },
  365. { title: "项目编号", align: "center", key: "order_no", minWidth: 200 },
  366. {
  367. title: "项目名称",
  368. align: "center",
  369. key: "residential_name",
  370. minWidth: 200,
  371. },
  372. { title: "计划单号", align: "center", key: "plan_no", minWidth: 200 },
  373. // {
  374. // title: "订单类型",
  375. // align: "center",
  376. // key: "order_type",
  377. // minWidth: 150,
  378. // render(h, params) {
  379. // return h("span", {}, params.row.order_type == 1 ? "工装" : "家装");
  380. // },
  381. // },
  382. {
  383. title: "订单状态",
  384. align: "center",
  385. key: "state",
  386. minWidth: 150,
  387. render: (h, params) =>
  388. h(
  389. "span",
  390. {},
  391. params.row.state == 0
  392. ? "未派工"
  393. : params.row.state == 1
  394. ? "派工中"
  395. : params.row.state == 2
  396. ? "完成"
  397. : ""
  398. ),
  399. },
  400. // { title: "业务员", align: "center", key: "nickname", minWidth: 150 },
  401. {
  402. title: "紧急程度",
  403. align: "center",
  404. key: "warning_state",
  405. minWidth: 150,
  406. slot: "basicTypeSet",
  407. },
  408. {
  409. title: "计划开始时间",
  410. align: "center",
  411. minWidth: 200,
  412. key: "plan_start_time",
  413. render: (h, params) =>
  414. h("span", {}, this.func.replaceDate(params.row.plan_start_time, 1)),
  415. },
  416. {
  417. title: "计划结束时间",
  418. align: "center",
  419. minWidth: 200,
  420. key: "plan_end_time",
  421. render: (h, params) =>
  422. h("span", {}, this.func.replaceDate(params.row.plan_end_time, 1)),
  423. },
  424. {
  425. title: "生产进度",
  426. align: "center",
  427. key: "complete_rate",
  428. minWidth: 100,
  429. render: (h, params) =>
  430. h("span", {}, parseInt(params.row.complete_rate * 100) + "%"),
  431. },
  432. {
  433. title: "预估交付日期",
  434. align: "center",
  435. key: "predict_time",
  436. minWidth: 200,
  437. render: (h, params) =>
  438. h("span", {}, this.func.replaceDate(params.row.predict_time, 1)),
  439. },
  440. {
  441. title: "操作",
  442. align: "center",
  443. key: "set",
  444. slot: "set",
  445. fixed: "right",
  446. width: "150",
  447. },
  448. ],
  449. tableData: [],
  450. showModal:false,
  451. page_index: 1,
  452. currencyPageId:null,
  453. page_size: 10,
  454. total: 0,
  455. proxyObj: {},
  456. selects: [],
  457. tableheaders: [],
  458. userList: [],
  459. //详情页返回保留搜索数据
  460. corssPageData: localStorage.getItem("corssPageData")
  461. ? JSON.parse(localStorage.getItem("corssPageData"))
  462. : {},
  463. warningList: [],
  464. };
  465. },
  466. beforeRouteEnter(to, from, next) {
  467. next((vm) => {
  468. if (from.path != "/cms/productionorderlist/productionplanlist/details") {
  469. localStorage.removeItem("corssPageData");
  470. } else {
  471. vm.firstEnter = 1;
  472. }
  473. });
  474. },
  475. beforeRouteLeave(to, from, next) {
  476. if (to.path == "/cms/productionorderlist/productionplanlist/details") {
  477. (this.corssPageData.page_index = this.page_index),
  478. (this.corssPageData.page_size = this.page_size),
  479. localStorage.setItem(
  480. "corssPageData",
  481. JSON.stringify(this.corssPageData)
  482. );
  483. } else {
  484. localStorage.removeItem("corssPageData");
  485. }
  486. next((vm) => {});
  487. },
  488. created() {
  489. // 获取紧急程度
  490. this.axios.get("/api/warning_list").then((res) => {
  491. this.warningList = res.data.data;
  492. });
  493. this.axios
  494. .get("/api/employee_list")
  495. .then((res) => (this.userList = res.data));
  496. //this.axios.get('/api/employee_list').then(res => { this.employeeList = res.data })
  497. this.currencyPageId = this.$store.state.navgationData[0].sub[0].sub[0].id;
  498. },
  499. computed: {
  500. ...mapState(["persimissionData"]),
  501. computedTable() {
  502. // if (this.tableheaders.length < 1) {
  503. return this.tableColums;
  504. // }
  505. // return this.func.computedHeader(this.tableheaders, this.tableColums)
  506. },
  507. set_list() {
  508. return [
  509. {
  510. title: "项目编号",
  511. name: "Input",
  512. serverName: "order_no",
  513. placeholder: "请输入项目编号",
  514. value: "",
  515. },
  516. {
  517. title: "项目名称",
  518. name: "Input",
  519. serverName: "residential_name",
  520. placeholder: "请选择项目名称",
  521. value: "",
  522. },
  523. // {
  524. // title: "订单类型",
  525. // name: "Select",
  526. // placeholder: "请选择",
  527. // serverName: "order_type",
  528. // value: "",
  529. // option: [
  530. // { label: "工装", value: 1 },
  531. // { label: "家装", value: 0 },
  532. // ],
  533. // },
  534. {
  535. title: "计划单号",
  536. name: "Input",
  537. serverName: "plan_no",
  538. placeholder: "请填写计划单号",
  539. value: "",
  540. },
  541. // {
  542. // title: "业务员",
  543. // name: "Select",
  544. // serverName: "nickname",
  545. // placeholder: "请选择",
  546. // value: "",
  547. // optionName: "nickname",
  548. // optionValue: "id",
  549. // option: this.userList,
  550. // },
  551. {
  552. title: "计划开始时间",
  553. name: "Input",
  554. start_server: "start_time",
  555. end_server: "end_time",
  556. start_value: "",
  557. end_value: "",
  558. isDate: true,
  559. serverName: "id2",
  560. start_placeholder: "开始日期",
  561. end_placeholder: "结束日期",
  562. },
  563. {
  564. title: "紧急程度",
  565. name: "Select",
  566. serverName: "warning_state",
  567. placeholder: "请选择",
  568. value: "",
  569. optionName: "title",
  570. optionValue: "id",
  571. option: this.warningList,
  572. },
  573. {
  574. title: "订单状态",
  575. name: "Select",
  576. placeholder: "请选择",
  577. serverName: "state",
  578. value: "",
  579. option: [
  580. { label: "未派工", value: 0 },
  581. { label: "派工中", value: 1 },
  582. { label: "完成", value: 2 },
  583. ],
  584. },
  585. ];
  586. },
  587. },
  588. methods: {
  589. handleModalOk(){
  590. this.formModalTableData.forEach((element, index) => {
  591. element.sort = index;
  592. });
  593. this.tableModalTableData.forEach((element, index) => {
  594. element.sort = index;
  595. });
  596. this.axios({
  597. method: "post",
  598. url: "/api/update/table",
  599. data: {
  600. id: this.currencyPageId,
  601. result: {
  602. formSet: this.formModalTableData,
  603. tableSet: this.tableModalTableData,
  604. },
  605. },
  606. }).then((res) => {
  607. this.$Message.success(res.msg);
  608. this.init(this.proxyObj);
  609. });
  610. },
  611. init(row) {
  612. const { order_no } = this.$route.query;
  613. if (order_no) {
  614. row.order_no = order_no;
  615. this.set_list[0].value = order_no;
  616. }
  617. row.sub_state = 5;
  618. if (this.firstEnter == 1) {
  619. this.corssPageData = JSON.parse(localStorage.getItem("corssPageData"));
  620. row = this.corssPageData;
  621. this.proxyObj = row;
  622. this.searchData(row);
  623. } else {
  624. this.page_index = 1;
  625. row.page_index = this.page_index;
  626. row.page_size = this.page_size;
  627. this.proxyObj = row;
  628. this.getData(row);
  629. }
  630. },
  631. searchData(row) {
  632. if (this.firstEnter == 1) {
  633. this.page_index = this.corssPageData.page_index;
  634. this.page_size = this.corssPageData.page_size;
  635. this.set_list[0].value = this.corssPageData.order_no;
  636. this.set_list[1].value = this.corssPageData.residential_name;
  637. this.set_list[3].value = this.corssPageData.warning_state;
  638. this.set_list[4].value = this.corssPageData.state;
  639. this.set_list[2].start_value = this.corssPageData.start_time
  640. ? this.corssPageData.start_time
  641. : "";
  642. this.set_list[2].end_value = this.corssPageData.end_time
  643. ? this.corssPageData.end_time
  644. : "";
  645. this.corssPageData.type = this.$route.query.type;
  646. this.getData(this.corssPageData);
  647. } else {
  648. this.page_index = 1;
  649. row.page_index = this.page_index;
  650. row.page_size = this.page_size;
  651. this.corssPageData.order_no = this.set_list[0].value;
  652. this.corssPageData.residential_name = this.set_list[1].value;
  653. this.corssPageData.warning_state = this.set_list[3].value;
  654. this.corssPageData.state = this.set_list[4].value;
  655. this.corssPageData.start_time = this.func.setDate(
  656. this.set_list[2].start_value
  657. );
  658. this.corssPageData.end_time = this.func.setDate(
  659. this.set_list[2].end_value
  660. );
  661. this.proxyObj = row;
  662. this.getData(row);
  663. }
  664. },
  665. changePage(e) {
  666. this.page_index = e;
  667. this.proxyObj.page_index = this.page_index;
  668. this.proxyObj.page_size = this.page_size;
  669. this.getData(this.proxyObj);
  670. },
  671. changeSize(e) {
  672. this.page_size = e;
  673. this.proxyObj.page_size = this.page_size;
  674. this.getData(this.proxyObj);
  675. },
  676. getData(row) {
  677. this.axios("/api/orders_produce_plan_list", { params: row }).then(
  678. (res) => {
  679. this.firstEnter++;
  680. this.tableData = res.data.data;
  681. this.total = res.data.total;
  682. // this.tableheaders = res.data.tableSet || []
  683. }
  684. );
  685. },
  686. goDetial(row) {
  687. this.$router.push({
  688. path: "/cms/productionorderlist/productionplanlist/details",
  689. query: {
  690. order_no: row.order_no,
  691. plan_no: row.plan_no,
  692. },
  693. });
  694. },
  695. onDragDrop(a, b, table, type) {
  696. if (type == 2 && (a == 0 || b == 0)) {
  697. return this.$Message.warning("全选位置不可变");
  698. }
  699. table.splice(b, 0, ...table.splice(a, 1));
  700. },
  701. handleDispatchType(row) {
  702. console.log("row :>> ", row);
  703. this.$router.push({
  704. path: "/cms/Dispatching/Dispatching",
  705. query: {
  706. order_no: row.order_no,
  707. plan_no: row.plan_no,
  708. },
  709. });
  710. },
  711. dispatchList(row) {
  712. this.dispatchOrder({
  713. params: {
  714. order_no: Array.isArray(row) ? this.selects.join(",") : row.order_no,
  715. },
  716. then: () => this.getData(this.proxyObj),
  717. });
  718. },
  719. selectTable(e) {
  720. let result = [];
  721. e.map((v) => result.push(v.order_no));
  722. this.selects = result;
  723. },
  724. setupTableHeader() {
  725. this.showModal = true;
  726. return;
  727. // this.tableheaders.length < 1
  728. // ? (this.tableheaders = this.tableColums.reduce(
  729. // (pre, cur) => pre.concat(cur.key),
  730. // []
  731. // ))
  732. // : "";
  733. // this.$setTableheader({
  734. // list: this.tableColums,
  735. // selects: this.tableheaders,
  736. // then: (result) => {
  737. // this.tableheaders = result;
  738. // this.axios
  739. // .post("/api/update/table", { id: this.$route.query.id, result })
  740. // .then((res) => {
  741. // if (res.code == 200) {
  742. // this.$Message.success(res.msg);
  743. // let data =[];
  744. // for(let i = 0 ; i++ ; i<this.tableColums){
  745. // if(this.tableColums[i].title.indexOf(result)>=0){
  746. // data.push(this.tableColums[i])
  747. // }
  748. // }
  749. // this.computedTable = data
  750. // }
  751. // });
  752. // },
  753. // });
  754. },
  755. },
  756. };
  757. </script>
  758. <style lang="scss" scoped>
  759. .pageSlotStyle {
  760. display: flex;
  761. justify-content: center;
  762. margin-top: 20px;
  763. }
  764. .modal_content {
  765. display: flex;
  766. justify-content: center;
  767. // width: 500px;
  768. }
  769. </style>