list.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. <template>
  2. <div class="BidsList">
  3. <FullPage
  4. title="工装订单列表"
  5. :list="set_list"
  6. @init="init"
  7. :loading="loading"
  8. @searchData="init"
  9. @selectTable="selectTable"
  10. @changePage="changePage"
  11. @changeSize="changeSize"
  12. :tableColums="computedTable"
  13. :showPage="false"
  14. :tableData="tableData"
  15. :page_index="page_index"
  16. :total="total"
  17. >
  18. <div slot="titleButton" style="display: flex">
  19. <Upload
  20. name="your_file"
  21. :show-upload-list="false"
  22. :headers="headers"
  23. :on-error="uploadError"
  24. :on-success="uploadSuccess"
  25. :action="$store.state.ip + '/api/order_area_import'"
  26. >
  27. <Button type="success" ghost icon="md-exit" style="margin-right: 10px"
  28. >导入</Button
  29. >
  30. </Upload>
  31. <Button
  32. @click="exportData"
  33. type="warning"
  34. ghost
  35. icon="md-return-left"
  36. style="margin-right: 10px"
  37. >导出</Button
  38. >
  39. <Button
  40. @click="handleToEditpage(1)"
  41. type="primary"
  42. ghost
  43. style="margin-right: 10px"
  44. >新增</Button
  45. >
  46. </div>
  47. <div slot="navButton" style="display: flex">
  48. <Button
  49. v-if="persimissionData['表头设置'] || persimissionData.all"
  50. @click="setupTableHeader"
  51. type="primary"
  52. style="margin-right: 10px"
  53. ghost
  54. icon="ios-cog"
  55. >设置</Button
  56. >
  57. </div>
  58. <template slot="basicTypeSet" slot-scope="{ row }">
  59. <div>
  60. <span
  61. v-for="item in warningList"
  62. :key="item.id"
  63. :style="{ color: item.color }"
  64. v-show="item.id == row.warning_state"
  65. >{{ item.title }}</span
  66. >
  67. </div>
  68. </template>
  69. <template slot="set" slot-scope="{ row, index }">
  70. <div>
  71. <a
  72. style="margin: 0 5px"
  73. :disabled="row.sub_status != 0"
  74. @click="handleSet(row, index, 1)"
  75. >深化</a
  76. >
  77. <a
  78. style="margin: 0 5px"
  79. :disabled="row.sub_status != 0"
  80. @click="handleSet(row, index, 2)"
  81. >编辑</a
  82. >
  83. <a style="margin: 0 5px" @click="handleSet(row, index, 3)">详情</a>
  84. <a
  85. style="margin: 0 5px"
  86. :disabled="row.sub_status != 0"
  87. @click="handleSet(row, index, 4)"
  88. >删除</a
  89. >
  90. </div>
  91. </template>
  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. <Modal
  108. v-model="processModal"
  109. title="下深化"
  110. @on-ok="handleProcess"
  111. @on-cancel="processModal = false"
  112. >
  113. <div>
  114. <div class="process_modal">
  115. <span>深化人员:</span>
  116. <Select v-model="process_man" style="width: 150px">
  117. <Option
  118. v-for="item in processManList"
  119. :key="item.id"
  120. :label="item.nickname"
  121. :value="item.id"
  122. ></Option>
  123. </Select>
  124. </div>
  125. <div class="process_modal">
  126. <span>选择时间:</span>
  127. <DatePicker
  128. type="date"
  129. v-model="process_start_time"
  130. placeholder="年/月/日"
  131. style="width: 150px"
  132. ></DatePicker>
  133. <DatePicker
  134. type="date"
  135. v-model="process_end_time"
  136. placeholder="年/月/日"
  137. style="width: 150px"
  138. ></DatePicker>
  139. </div>
  140. </div>
  141. </Modal>
  142. <Modal
  143. v-model="showModal"
  144. title="设置"
  145. @on-ok="handleModalOk"
  146. @on-cancel="showModal = false"
  147. >
  148. <div class="modal_content">
  149. <Tabs value="name1">
  150. <TabPane label="表单设置" name="name1">
  151. <Table
  152. :columns="formModalColumns"
  153. border
  154. :data="formModalTableData"
  155. ></Table>
  156. <!-- @on-drag-drop="(a,b)=>onDragDrop(a,b,formModalTableData)" -->
  157. </TabPane>
  158. <TabPane label="表头设置" name="name2">
  159. <Table
  160. :columns="tableModalColumns"
  161. border
  162. draggable
  163. @on-drag-drop="(a, b) => onDragDrop(a, b, tableModalTableData)"
  164. :data="tableModalTableData"
  165. ></Table>
  166. </TabPane>
  167. </Tabs>
  168. </div>
  169. </Modal>
  170. </div>
  171. </template>
  172. <script>
  173. // 这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  174. // 例如:import 《组件名称》 from '《组件路径》';
  175. import { mapState } from "vuex";
  176. export default {
  177. name: "BidSystemContractList",
  178. data() {
  179. // 这里存放数据
  180. return {
  181. tableColums: [
  182. {
  183. type: "selection",
  184. align: "center",
  185. key: "selection",
  186. minWidth: 100,
  187. fixed: "left",
  188. title: "全选",
  189. },
  190. { title: "订单号", align: "center", key: "order_no", minWidth: 150 },
  191. {
  192. title: "项目名称",
  193. align: "center",
  194. key: "residential_name",
  195. minWidth: 120,
  196. },
  197. { title: "详细地址", align: "center", key: "address", minWidth: 200 },
  198. // {
  199. // title: '订单类型', align: 'center', key: 'renovation_type', minWidth: 100,
  200. // render: (h, params) => h('span', {}, params.row.renovation_type == 1 ? '工装' : '家装')
  201. // },
  202. {
  203. title: "客户姓名",
  204. align: "center",
  205. key: "client_name",
  206. minWidth: 120,
  207. },
  208. { title: "手机号", align: "center", key: "mobile", minWidth: 150 },
  209. {
  210. title: "紧急程度",
  211. align: "center",
  212. key: "warning_state",
  213. minWidth: 100,
  214. slot: "basicTypeSet",
  215. },
  216. {
  217. title: "业务员",
  218. align: "center",
  219. key: "salesman",
  220. minWidth: 100,
  221. // render: (h, params) => {
  222. // let name = ''
  223. // this.salesmanList.forEach(el => {
  224. // if (el.id == params.row.salesman) {
  225. // name = el.nickname
  226. // }
  227. // })
  228. // return h('span', {}, name
  229. // )
  230. // }
  231. },
  232. {
  233. title: "开始日期",
  234. align: "center",
  235. key: "start_time",
  236. minWidth: 150,
  237. render: (h, params) =>
  238. h("span", {}, this.func.replaceDateNoHMS(params.row.start_time)),
  239. },
  240. {
  241. title: "交付日期",
  242. align: "center",
  243. key: "end_time",
  244. minWidth: 150,
  245. render: (h, params) =>
  246. h("span", {}, this.func.replaceDateNoHMS(params.row.end_time)),
  247. },
  248. {
  249. title: "订单状态",
  250. align: "center",
  251. key: "state",
  252. minWidth: 100,
  253. render: (h, params) =>
  254. h(
  255. "span",
  256. {},
  257. params.row.state == 0
  258. ? "待审核"
  259. : params.row.warning_state == 1
  260. ? "待拆单"
  261. : params.row.warning_state == 2
  262. ? "待生产"
  263. : "已完成"
  264. ),
  265. },
  266. {
  267. title: "下单日期",
  268. align: "center",
  269. key: "crt_time",
  270. minWidth: 150,
  271. render: (h, params) =>
  272. h("span", {}, this.func.replaceDate(params.row.crt_time)),
  273. },
  274. {
  275. title: "操作",
  276. align: "center",
  277. key: "set",
  278. slot: "set",
  279. fixed: "right",
  280. minWidth: 200,
  281. fixed: "right",
  282. },
  283. ],
  284. tableData: [],
  285. page_index: 1,
  286. page_size: 10,
  287. total: 0,
  288. loading: false,
  289. proxyObj: {},
  290. headers: { Authorization: localStorage.getItem("token") },
  291. selects: [],
  292. salesmanList: [],
  293. processModal: false,
  294. process_man: "",
  295. processManList: [],
  296. process_start_time: "",
  297. process_end_time: "",
  298. order_no: "",
  299. showModal: false,
  300. currencyPageId: null,
  301. formModalColumns: [
  302. { type: "index", minWidth: 30, align: "center" },
  303. {
  304. title: "是否展示",
  305. align: "center",
  306. key: "is_show",
  307. minWidth: 60,
  308. render: (h, params) => {
  309. const { row, index } = params;
  310. const currentRow = JSON.parse(
  311. JSON.stringify(this.formModalTableData[index])
  312. );
  313. return h("Checkbox", {
  314. props: {
  315. value: currentRow.is_show,
  316. },
  317. on: {
  318. "on-change": (e) => {
  319. currentRow.is_show = e;
  320. this.formModalTableData.splice(index, 1, currentRow);
  321. },
  322. },
  323. });
  324. },
  325. },
  326. {
  327. title: "字段名",
  328. align: "center",
  329. key: "value",
  330. minWidth: 100,
  331. render: (h, params) => {
  332. const { row, index } = params;
  333. const currentRow = JSON.parse(
  334. JSON.stringify(this.formModalTableData[index])
  335. );
  336. return h("Input", {
  337. props: {
  338. value: currentRow.value,
  339. type: "text",
  340. },
  341. on: {
  342. "on-change": (e) => {
  343. currentRow.value = e.target.value;
  344. this.formModalTableData.splice(index, 1, currentRow);
  345. },
  346. },
  347. });
  348. },
  349. },
  350. ],
  351. formModalTableData: [],
  352. tableModalColumns: [
  353. { type: "index", minWidth: 30, align: "center" },
  354. {
  355. title: "是否展示",
  356. align: "center",
  357. key: "is_show",
  358. minWidth: 60,
  359. render: (h, params) => {
  360. const { row, index } = params;
  361. const currentRow = JSON.parse(
  362. JSON.stringify(this.tableModalTableData[index])
  363. );
  364. return h("Checkbox", {
  365. props: {
  366. value: currentRow.is_show,
  367. },
  368. on: {
  369. "on-change": (e) => {
  370. currentRow.is_show = e;
  371. this.tableModalTableData.splice(index, 1, currentRow);
  372. },
  373. },
  374. });
  375. },
  376. },
  377. {
  378. title: "字段名",
  379. align: "center",
  380. key: "value",
  381. minWidth: 100,
  382. render: (h, params) => {
  383. const { row, index } = params;
  384. const currentRow = JSON.parse(
  385. JSON.stringify(this.tableModalTableData[index])
  386. );
  387. return h("Input", {
  388. props: {
  389. value: currentRow.value,
  390. type: "text",
  391. },
  392. on: {
  393. "on-change": (e) => {
  394. currentRow.value = e.target.value;
  395. this.tableModalTableData.splice(index, 1, currentRow);
  396. },
  397. },
  398. });
  399. },
  400. },
  401. ],
  402. tableModalTableData: [
  403. // { is_show: true, key: 'selection', value: '全选' },
  404. // { is_show: true, key: 'order_no', value: '订单编号' },
  405. // { is_show: true, key: 'residential_name', value: '项目名称' },
  406. // { is_show: true, key: 'address', value: '详细地址' },
  407. // { is_show: true, key: 'client_name', value: '客户姓名' },
  408. // { is_show: true, key: 'mobile', value: '手机号' },
  409. // { is_show: true, key: 'warning_state', value: '紧急程度' },
  410. // { is_show: true, key: 'salesman', value: '业务员' },
  411. // { is_show: true, key: 'start_time', value: '开始日期' },
  412. // { is_show: true, key: 'end_time', value: '交付日期' },
  413. // { is_show: true, key: 'state', value: '订单状态' },
  414. // { is_show: true, key: 'crt_time', value: '下单日期' },
  415. // { is_show: true, key: 'set', value: '操作' },
  416. ],
  417. warningList: [],
  418. };
  419. },
  420. // 生命周期 - 创建完成(可以访问当前this实例)
  421. created() {
  422. this.currencyPageId = this.$store.state.navgationData[0].sub[1].sub[0].id;
  423. // 获取紧急程度
  424. this.axios.get("/api/warning_list").then((res) => {
  425. this.warningList = res.data.data;
  426. });
  427. },
  428. // 生命周期 - 挂载完成(可以访问DOM元素)
  429. mounted() {
  430. this.axios("/api/user").then((res) => {
  431. (this.salesmanList = res.data.data),
  432. (this.processManList = res.data.data);
  433. });
  434. },
  435. methods: {
  436. handleProcess() {
  437. this.axios({
  438. method: "get",
  439. url: "/api/order_area_pull",
  440. params: {
  441. order_no: this.order_no,
  442. sub_status: 1,
  443. process_man: this.process_man,
  444. process_start_time: this.func.replaceDateNoHMS(
  445. this.process_start_time
  446. ),
  447. process_end_time: this.func.replaceDateNoHMS(this.process_end_time),
  448. },
  449. })
  450. .then((res) => {
  451. this.$Message.success(res.msg);
  452. this.getData(this.proxyObj);
  453. })
  454. .catch((err) => {});
  455. },
  456. //1深化 2编辑 3详情 4删除 0新增
  457. handleSet(row, index, type) {
  458. switch (type) {
  459. case 1:
  460. this.processModal = true;
  461. this.order_no = row.order_no;
  462. break;
  463. case 2:
  464. this.$router.push({
  465. path: "/cms/BidSystem/ContractList/edit",
  466. query: {
  467. type,
  468. order_no: row.order_no,
  469. },
  470. });
  471. break;
  472. case 3:
  473. this.$router.push({
  474. path: "/cms/BidSystem/ContractList/info",
  475. query: {
  476. type,
  477. order_no: row.order_no,
  478. },
  479. });
  480. break;
  481. case 4:
  482. this.$Modal.confirm({
  483. title: "确认删除?",
  484. content: "此操作确认后不可恢复,请确认!",
  485. onOk: () => {
  486. this.axios({
  487. method: "get",
  488. url: "/api/order_area_del",
  489. params: {
  490. order_no: row.order_no,
  491. },
  492. })
  493. .then((res) => {
  494. this.$Message.success(res.msg);
  495. this.getData(this.proxyObj);
  496. })
  497. .catch((err) => {});
  498. },
  499. onCancel: () => {},
  500. });
  501. break;
  502. }
  503. },
  504. handleToEditpage(type) {
  505. this.$router.push({
  506. path: "/cms/BidSystem/ContractList/edit",
  507. query: {
  508. type,
  509. },
  510. });
  511. },
  512. init(row) {
  513. this.page_index = 1;
  514. row.page_index = this.page_index;
  515. row.page_size = this.page_size;
  516. // 0 业务单
  517. row.sub_status = 0;
  518. this.proxyObj = row;
  519. this.getData(row);
  520. },
  521. getData(row) {
  522. this.loading = true;
  523. this.axios("/api/order_area", { params: row }).then((res) => {
  524. this.loading = false;
  525. this.tableData = res.data.data;
  526. this.tableModalTableData = res.data.tableSet.tableSet || [];
  527. this.total = res.data.total;
  528. });
  529. },
  530. setupTableHeader() {
  531. this.showModal = true;
  532. return;
  533. },
  534. changePage(e) {
  535. this.page_index = e;
  536. this.proxyObj.page_index = this.page_index;
  537. this.getData(this.proxyObj);
  538. },
  539. changeSize(e) {
  540. this.page_size = e;
  541. this.proxyObj.page_size = this.page_size;
  542. this.getData(this.proxyObj);
  543. },
  544. async exportData() {
  545. const res = await this.axios("/api/measure_orders_export", {
  546. params: { ...this.proxyObj },
  547. });
  548. if (res.code == 200) {
  549. let url = `${this.$store.state.ip}/api/storage/${res.data.file}`;
  550. location.href = url;
  551. }
  552. },
  553. uploadSuccess(res) {
  554. if (res.code == 200) {
  555. this.$Message.success(res.msg || "上传成功");
  556. } else {
  557. this.$Message.warning(res.msg || "上传失败");
  558. }
  559. this.getData(this.proxyObj);
  560. },
  561. uploadError(err) {
  562. this.$Message.error(err.msg || "上传失败");
  563. },
  564. selectTable(e) {
  565. this.selects = e;
  566. },
  567. onDragDrop(a, b, table) {
  568. table.splice(b, 0, ...table.splice(a, 1));
  569. },
  570. handleModalOk() {
  571. this.formModalTableData.forEach((element, index) => {
  572. element.sort = index;
  573. });
  574. this.tableModalTableData.forEach((element, index) => {
  575. element.sort = index;
  576. });
  577. this.axios({
  578. method: "post",
  579. url: "/api/update/table",
  580. data: {
  581. id: this.currencyPageId,
  582. result: {
  583. formSet: this.formModalTableData || [],
  584. tableSet: this.tableModalTableData || [],
  585. },
  586. },
  587. })
  588. .then((res) => {
  589. this.$Message.success(res.msg);
  590. this.init(this.proxyObj);
  591. })
  592. .catch((err) => {});
  593. },
  594. },
  595. // 监听属性 类似于data概念
  596. computed: {
  597. ...mapState(["persimissionData"]),
  598. computedTable() {
  599. if (this.tableModalTableData.length < 1) {
  600. return this.tableColums;
  601. }
  602. return this.func.computedHeader(
  603. this.tableModalTableData,
  604. this.tableColums
  605. );
  606. },
  607. set_list() {
  608. return [
  609. {
  610. title: "订单编号",
  611. serverName: "order_no",
  612. name: "Input",
  613. value: "",
  614. placeholder: "请输入订单号",
  615. },
  616. {
  617. title: "项目名称",
  618. name: "Input",
  619. placeholder: "请输入",
  620. value: "",
  621. serverName: "residential_name",
  622. },
  623. {
  624. title: "客户昵称",
  625. name: "Input",
  626. placeholder: "请输入",
  627. value: "",
  628. serverName: "client_name",
  629. },
  630. {
  631. title: "手机号",
  632. name: "Input",
  633. placeholder: "请输入",
  634. value: "",
  635. serverName: "mobile",
  636. },
  637. {
  638. title: "订单状态",
  639. name: "Select",
  640. placeholder: "请选择",
  641. serverName: "state",
  642. value: "",
  643. option: [
  644. { label: "待审核", value: 0 },
  645. { label: "待拆单", value: 1 },
  646. { label: "待生产", value: 2 },
  647. { label: "已完成", value: 3 },
  648. ],
  649. },
  650. // {
  651. // title: '订单类型', name: 'Select', placeholder: '请选择', serverName: 'type', value: '',
  652. // option: [
  653. // { label: '工装', value: 1 },
  654. // { label: '家装', value: 2 },
  655. // ]
  656. // },
  657. {
  658. title: "紧急程度",
  659. name: "Select",
  660. serverName: "warning_state",
  661. placeholder: "请选择",
  662. value: "",
  663. optionName: "title",
  664. optionValue: "id",
  665. option: this.warningList,
  666. },
  667. ];
  668. },
  669. },
  670. // 监控data中的数据变化
  671. watch: {},
  672. beforeCreate() {}, // 生命周期 - 创建之前
  673. beforeMount() {}, // 生命周期 - 挂载之前
  674. beforeUpdate() {}, // 生命周期 - 更新之前
  675. updated() {}, // 生命周期 - 更新之后
  676. beforeDestroy() {}, // 生命周期 - 销毁之前
  677. destroyed() {}, // 生命周期 - 销毁完成
  678. activated() {}, // 如果页面有keep-alive缓存功能,这个函数会触发
  679. };
  680. </script>
  681. <style lang='scss' scoped>
  682. .pageSlotStyle {
  683. display: flex;
  684. justify-content: center;
  685. margin-top: 40px;
  686. }
  687. .process_modal {
  688. display: flex;
  689. justify-content: center;
  690. align-items: center;
  691. padding: 10px;
  692. }
  693. </style>