index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. <template>
  2. <div>
  3. <by-bill :propConfig="config" @search="search" @onSmt="doSave" ref="bill" @onAdd="onAdd" @onOrder="onOrder"
  4. @resert="resert" @clickHandle="clickHandle" @detail="openEdit">
  5. </by-bill>
  6. </div>
  7. </template>
  8. <script lang="ts">
  9. import { Component, Prop, Vue, Watch } from "vue-property-decorator";
  10. import api from "@/api/order";
  11. import Assembly from "@/benyun/components/Assembly/order.vue";
  12. @Component
  13. export default class OrderTask extends Vue {
  14. // 右边
  15. baseURL : any = process.env.VUE_APP_BASE_API
  16. setStatusData : any = ''
  17. timeNum = 0;
  18. timer : any = null
  19. config : any = {
  20. attr: {
  21. activeName: 'all'
  22. },
  23. // 单据
  24. bill: {
  25. tool: {
  26. // tools: {
  27. // smt: true,
  28. // },
  29. customTools: [
  30. {
  31. name: '拆单', icon: 'el-icon-plus', audit: [''], event: {
  32. click: () => {
  33. // (this as any).orderTaking()
  34. }
  35. }
  36. }
  37. ]
  38. },
  39. form: {
  40. attr: {
  41. size: 'small',
  42. },
  43. columns: [
  44. [
  45. {
  46. span: 8,
  47. label: '机构名称',
  48. prop: 'organizationName',
  49. component: 'by-input',
  50. },
  51. {
  52. span: 8,
  53. label: '单据编号',
  54. slot: true,
  55. prop: 'orderNumber',
  56. component: 'by-input',
  57. },
  58. {
  59. span: 8,
  60. label: '机构',
  61. slot: true,
  62. prop: 'organizationId',
  63. component: 'by-input',
  64. },
  65. {
  66. span: 8,
  67. label: '交货地点',
  68. slot: true,
  69. prop: 'deliveryAddress',
  70. component: 'by-input',
  71. },
  72. {
  73. span: 8,
  74. label: '交货时间',
  75. slot: true,
  76. prop: 'deliveryData',
  77. component: 'by-date-picker',
  78. compConfig: {
  79. format: 'yyyy-MM-dd',
  80. type: 'datetime'
  81. }
  82. },
  83. {
  84. span: 8,
  85. label: '交货人',
  86. slot: true,
  87. prop: 'delivery',
  88. component: 'by-input',
  89. },
  90. {
  91. span: 8,
  92. label: '联系方式',
  93. slot: true,
  94. prop: 'deliveryPhone',
  95. component: 'by-input',
  96. },
  97. {
  98. span: 8,
  99. label: '交货方式',
  100. slot: true,
  101. prop: 'deliveryWay',
  102. component: 'by-input',
  103. },
  104. {
  105. span: 8,
  106. label: '备注',
  107. slot: true,
  108. prop: 'remark',
  109. component: 'by-input',
  110. },
  111. ],
  112. ]
  113. }
  114. },
  115. // 综合
  116. all: {
  117. search: {
  118. attr: {
  119. size: 'mini',
  120. },
  121. columns: [
  122. [
  123. {
  124. span: 6,
  125. label: '机构名称',
  126. prop: 'organizationName',
  127. component: 'by-input',
  128. compConfig: {
  129. attr: {
  130. placeholder: '请输入机构名称',
  131. clearable: true
  132. },
  133. },
  134. },
  135. {
  136. span: 6,
  137. label: '单据编号',
  138. prop: 'orderNumber',
  139. component: 'by-input',
  140. compConfig: {
  141. attr: {
  142. placeholder: '请输入单据编号',
  143. clearable: true
  144. }
  145. }
  146. },
  147. {
  148. span: 6,
  149. label: '交货地点',
  150. prop: 'deliveryAddress',
  151. component: 'by-input',
  152. compConfig: {
  153. attr: {
  154. placeholder: '请输入交货地点',
  155. clearable: true
  156. }
  157. }
  158. },
  159. ],
  160. [
  161. {
  162. span: 6,
  163. label: '交货人',
  164. prop: 'delivery',
  165. component: 'by-input',
  166. compConfig: {
  167. attr: {
  168. placeholder: '请输入交货人',
  169. clearable: true
  170. }
  171. }
  172. },
  173. {
  174. span: 6,
  175. label: '交货时间',
  176. prop: 'deliveryData',
  177. component: 'by-date-picker',
  178. compConfig: {
  179. format: 'yyyy-MM-dd',
  180. type: 'datetime'
  181. }
  182. },
  183. ]
  184. ]
  185. },
  186. tool: {
  187. tools: {
  188. // export: true,
  189. search: true,
  190. refresh: true
  191. },
  192. customTools: [
  193. {
  194. name: '拆单', icon: 'el-icon-plus', audit: [''], event: {
  195. click: () => {
  196. // (this as any).orderTaking()
  197. }
  198. }
  199. }
  200. ]
  201. },
  202. table: {
  203. attr: {
  204. height: 600,
  205. size: 'mini',
  206. seq: true,
  207. align: 'center',
  208. checkbox: true
  209. },
  210. columns: [
  211. {
  212. width: 200,
  213. title: '机构名称',
  214. field: 'organizationName',
  215. isDetail: true,
  216. },
  217. {
  218. width: 180,
  219. title: '单据编号',
  220. field: 'orderNumber',
  221. },
  222. {
  223. width: 200,
  224. title: '交货地点',
  225. field: 'deliveryAddress',
  226. },
  227. {
  228. width: 150,
  229. title: '交货时间',
  230. field: 'deliveryData',
  231. },
  232. {
  233. title: '交货人',
  234. field: 'delivery',
  235. },
  236. {
  237. width: 120,
  238. title: '交货人联系方式',
  239. field: 'deliveryPhone',
  240. },
  241. {
  242. title: '交货方式',
  243. field: 'deliveryWay',
  244. },
  245. {
  246. title: '备注',
  247. field: 'remark',
  248. },
  249. {
  250. width: 110,
  251. title: '操作',
  252. action: true,
  253. plugins: [{
  254. icon: 'el-icon-edit',
  255. name: '查看',
  256. audit: '',
  257. event: {
  258. click: (item : any) => {
  259. (this as any).openEdit(item)
  260. }
  261. }
  262. }, {
  263. name: '拆单',
  264. event: {
  265. // click: (item : any) => (this as any).getOrder(item)
  266. }
  267. }]
  268. }
  269. ]
  270. }
  271. },
  272. // 回收站
  273. // recycleBin: {
  274. // search: {
  275. // attr: {
  276. // size: 'mini',
  277. // },
  278. // columns: [
  279. // [
  280. // {
  281. // span: 6,
  282. // label: '机构名称',
  283. // prop: 'organizationName',
  284. // component: 'by-input',
  285. // compConfig: {
  286. // attr: {
  287. // placeholder: '请输入机构名称',
  288. // clearable: true
  289. // },
  290. // },
  291. // },
  292. // {
  293. // span: 6,
  294. // label: '单据编号',
  295. // prop: 'orderNumber',
  296. // component: 'by-input',
  297. // compConfig: {
  298. // attr: {
  299. // placeholder: '请输入单据编号',
  300. // clearable: true
  301. // }
  302. // }
  303. // },
  304. // {
  305. // span: 6,
  306. // label: '交货地点',
  307. // prop: 'deliveryAddress',
  308. // component: 'by-input',
  309. // compConfig: {
  310. // attr: {
  311. // placeholder: '请输入交货地点',
  312. // clearable: true
  313. // }
  314. // }
  315. // },
  316. // ],
  317. // [
  318. // {
  319. // span: 6,
  320. // label: '交货人',
  321. // prop: 'delivery',
  322. // component: 'by-input',
  323. // compConfig: {
  324. // attr: {
  325. // placeholder: '请输入交货人',
  326. // clearable: true
  327. // }
  328. // }
  329. // },
  330. // {
  331. // span: 6,
  332. // label: '交货时间',
  333. // prop: 'deliveryData',
  334. // component: 'by-date-picker',
  335. // compConfig: {
  336. // format: 'yyyy-MM-dd hh:ss:mm',
  337. // type: 'datetime'
  338. // }
  339. // },
  340. // ]
  341. // ]
  342. // },
  343. // table: {
  344. // attr: {
  345. // height: 600,
  346. // size: 'mini',
  347. // seq: true,
  348. // align: 'center',
  349. // checkbox: true
  350. // },
  351. // columns: [
  352. // {
  353. // width: 70,
  354. // title: '单据编号',
  355. // field: 'orderNumber',
  356. // },
  357. // {
  358. // width: 200,
  359. // title: '机构名称',
  360. // field: 'organizationName',
  361. // },
  362. // {
  363. // width: 200,
  364. // title: '交货地点',
  365. // field: 'deliveryAddress',
  366. // },
  367. // {
  368. // width: 150,
  369. // title: '交货时间',
  370. // field: 'deliveryData',
  371. // },
  372. // {
  373. // title: '交货人',
  374. // field: 'delivery',
  375. // },
  376. // {
  377. // title: '交货人联系方式',
  378. // field: 'deliveryPhone',
  379. // },
  380. // {
  381. // title: '交货方式',
  382. // field: 'deliveryWay',
  383. // },
  384. // {
  385. // title: '备注',
  386. // field: 'remark',
  387. // },
  388. // ]
  389. // }
  390. // }
  391. }
  392. created() {
  393. this.timer = setInterval(() => {
  394. this.getDataList()
  395. }, 500)
  396. }
  397. // 工具栏方法
  398. clickHandle(e : any) {
  399. console.log(e);
  400. }
  401. // 保存新增
  402. doSave() {
  403. // (this.$refs.product as any).setShow(true)
  404. (this as any).$refs.bill.$refs.billForm.validate().then(() => {
  405. let query = (this as any).$refs.bill.$refs.billForm.getValue();
  406. // query.suborderList = [] // 子表单数据
  407. query.status = 0; // 默认未接单
  408. api.saveList(query, 'supplyPurchaseOrder').then((res : any) => {
  409. if (res.code === 200) {
  410. this.$message({
  411. type: 'success',
  412. message: '提交成功!'
  413. });
  414. this.getDataList();
  415. (this.$refs.bill as any).showTab = 'all';
  416. (this.$refs.bill as any).setBillFormValue({});
  417. } else this.failHandle(res)
  418. })
  419. })
  420. }
  421. // 保存修改
  422. orderTaking() {
  423. let query : any = (this as any).$refs.bill.$refs.billForm.getValue();
  424. api.updateList(query, 'supplyPurchaseOrder').then((res : any) => {
  425. if (res.code === 200) {
  426. this.$message({
  427. type: 'success',
  428. message: '保存成功!'
  429. });
  430. this.getDataList();
  431. (this.$refs.bill as any).showTab = 'all';
  432. (this.$refs.bill as any).setBillFormValue({});
  433. } else this.failHandle(res)
  434. })
  435. }
  436. getDataList() {
  437. if (!this.$refs.bill) {
  438. if (this.timeNum > 5) {
  439. clearInterval(this.timer)
  440. }
  441. this.timeNum++;
  442. return
  443. }
  444. clearInterval(this.timer)
  445. // submitState: 提交状态
  446. this.getPageList({}, 'all'); // 综合数据
  447. // recycleBin
  448. // this.getPageList({ submitState: 0 }, 'draftsBox'); // 草稿箱数据
  449. // this.getPageList({ submitState: 1 }, 'smt'); // 已提交数据
  450. // this.getSelectDeleteList('supplyPurchaseOrder') // 回收站数据
  451. }
  452. // 获取分页数据
  453. getPageList(query : any, type : any) {
  454. api.pageList(query, 'supplyPurchaseOrder').then((res : any) => {
  455. if (res.code === 200) {
  456. (this.$refs.bill as any).setTabTableValue(type, res.data.records);
  457. let page = {
  458. pageNo: res.data.current, //当前页
  459. pageSize: res.data.size, //每页条数
  460. total: res.data.total //总条数
  461. };
  462. (this.$refs.bill as any).setTablePage(type, page)
  463. } else this.failHandle(res)
  464. })
  465. }
  466. // 回收站数据
  467. getSelectDeleteList(url:any){
  468. api.selectDeleteList(url).then((res : any) => {
  469. if (res.code === 200) {
  470. (this.$refs.bill as any).setTabTableValue('recycleBin', res.data);
  471. let page = {
  472. pageNo: res.data.current, //当前页
  473. pageSize: res.data.size, //每页条数
  474. total: res.data.total //总条数
  475. };
  476. (this.$refs.bill as any).setTablePage('recycleBin', page)
  477. } else this.failHandle(res)
  478. });
  479. }
  480. // 打开新增
  481. onAdd(e : any) {
  482. console.log(e);
  483. // this.orderType = '新增';
  484. (this.$refs.bill as any).setBillFormValue({}); // 设置单据表单数据
  485. (this.$refs.bill as any).showTab = 'bill';
  486. }
  487. // 打开编辑
  488. openEdit(e : any) {
  489. console.log(e);
  490. e = e.row ? e.row : e;
  491. // this.orderType = '编辑';
  492. (this.$refs.bill as any).setBillFormValue(e); // 设置单据表单数据
  493. (this.$refs.bill as any).showTab = 'bill';
  494. }
  495. // 搜索
  496. search(parames : any) {
  497. let query = parames.value
  498. if (parames.type === 'draftsBox') query.submitState = 0 // 草稿箱数据
  499. if (parames.type === 'smt') query.submitState = 1 // 已提交数据
  500. this.getPageList(query, parames.type) // 获取分页数据
  501. }
  502. // 接单
  503. getOrder(item : any) {
  504. api.ordersaccepting({ ids: item.id }, 'supplyPurchaseOrder').then((res : any) => {
  505. if (res.code === 200) {
  506. // 是否跳转销售订单 this.$router.push()
  507. this.getDataList();
  508. this.$message({
  509. type: 'success',
  510. message: '接单成功!'
  511. });
  512. } else this.failHandle(res)
  513. })
  514. }
  515. resert(parames : any) {
  516. console.log('重置回传参数', parames);
  517. }
  518. // 工具栏接单
  519. onOrder(n : string) {
  520. console.log(n + ':工具栏执行操作onOrder')
  521. }
  522. // 运行错误
  523. failHandle(err : any) {
  524. let msg = err.msg ? err.msg : '运行错误!';
  525. this.$message.error(msg)
  526. }
  527. }
  528. </script>