index.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  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. customTools: [
  27. {
  28. name: '接单', icon: 'el-icon-plus', audit: [''], event: {
  29. click: () => {
  30. // (this as any).getOrder()
  31. }
  32. }
  33. }
  34. ]
  35. },
  36. form: {
  37. attr: {
  38. size: 'small',
  39. },
  40. columns: [
  41. [
  42. {
  43. span: 8,
  44. label: '机构名称',
  45. prop: 'organizationName',
  46. component: 'by-input',
  47. },
  48. {
  49. span: 8,
  50. label: '状态',
  51. prop: 'status',
  52. component: 'by-select',
  53. compConfig: {
  54. attr: {
  55. placeholder: '请选择状态',
  56. clearable: true,
  57. data: [{
  58. value: 0,
  59. label: '未接单'
  60. }, {
  61. value: 1,
  62. label: '已接单'
  63. }]
  64. }
  65. }
  66. },
  67. {
  68. span: 8,
  69. label: '单据编号',
  70. slot: true,
  71. prop: 'orderNumber',
  72. component: 'by-input',
  73. },
  74. {
  75. span: 8,
  76. label: '机构',
  77. slot: true,
  78. prop: 'organizationId',
  79. component: 'by-input',
  80. },
  81. {
  82. span: 8,
  83. label: '交货地点',
  84. slot: true,
  85. prop: 'deliveryAddress',
  86. component: 'by-input',
  87. },
  88. {
  89. span: 8,
  90. label: '交货时间',
  91. slot: true,
  92. prop: 'deliveryData',
  93. component: 'by-date-picker',
  94. compConfig: {
  95. format: 'yyyy-MM-dd',
  96. type: 'datetime'
  97. }
  98. },
  99. {
  100. span: 8,
  101. label: '交货人',
  102. slot: true,
  103. prop: 'delivery',
  104. component: 'by-input',
  105. },
  106. {
  107. span: 8,
  108. label: '联系方式',
  109. slot: true,
  110. prop: 'deliveryPhone',
  111. component: 'by-input',
  112. },
  113. {
  114. span: 8,
  115. label: '交货方式',
  116. slot: true,
  117. prop: 'deliveryWay',
  118. component: 'by-input',
  119. },
  120. {
  121. span: 8,
  122. label: '备注',
  123. slot: true,
  124. prop: 'remark',
  125. component: 'by-input',
  126. },
  127. ],
  128. ]
  129. }
  130. },
  131. // 综合
  132. all: {
  133. search: {
  134. attr: {
  135. size: 'mini',
  136. },
  137. columns: [
  138. [
  139. {
  140. span: 6,
  141. label: '机构名称',
  142. prop: 'organizationName',
  143. component: 'by-input',
  144. compConfig: {
  145. attr: {
  146. placeholder: '请输入机构名称',
  147. clearable: true
  148. },
  149. },
  150. },
  151. {
  152. span: 6,
  153. label: '单据编号',
  154. prop: 'orderNumber',
  155. component: 'by-input',
  156. compConfig: {
  157. attr: {
  158. placeholder: '请输入单据编号',
  159. clearable: true
  160. }
  161. }
  162. },
  163. {
  164. span: 6,
  165. label: '交货地点',
  166. prop: 'deliveryAddress',
  167. component: 'by-input',
  168. compConfig: {
  169. attr: {
  170. placeholder: '请输入交货地点',
  171. clearable: true
  172. }
  173. }
  174. },
  175. ],
  176. [
  177. {
  178. span: 6,
  179. label: '交货人',
  180. prop: 'delivery',
  181. component: 'by-input',
  182. compConfig: {
  183. attr: {
  184. placeholder: '请输入交货人',
  185. clearable: true
  186. }
  187. }
  188. },
  189. {
  190. span: 6,
  191. label: '状态',
  192. prop: 'status',
  193. component: 'by-select',
  194. compConfig: {
  195. attr: {
  196. placeholder: '请选择状态',
  197. clearable: true,
  198. data: [{
  199. value: 0,
  200. label: '未接单'
  201. }, {
  202. value: 1,
  203. label: '已接单'
  204. }]
  205. }
  206. }
  207. },
  208. {
  209. span: 6,
  210. label: '交货时间',
  211. prop: 'deliveryData',
  212. component: 'by-date-picker',
  213. compConfig: {
  214. format: 'yyyy-MM-dd',
  215. type: 'datetime'
  216. }
  217. },
  218. ]
  219. ]
  220. },
  221. tool: {
  222. tools: {
  223. order: true,
  224. export: true,
  225. search: true,
  226. refresh: true
  227. }
  228. },
  229. table: {
  230. attr: {
  231. height: 600,
  232. size: 'mini',
  233. seq: true,
  234. align: 'center',
  235. checkbox: true
  236. },
  237. columns: [
  238. {
  239. width: 200,
  240. title: '机构名称',
  241. field: 'organizationName',
  242. isDetail: true,
  243. },
  244. {
  245. width: 120,
  246. title: '单据编号',
  247. field: 'orderNumber',
  248. },
  249. {
  250. width: 80,
  251. title: '状态',
  252. field: 'status',
  253. component: Assembly,
  254. },
  255. {
  256. width: 200,
  257. title: '交货地点',
  258. field: 'deliveryAddress',
  259. },
  260. {
  261. width: 150,
  262. title: '交货时间',
  263. field: 'deliveryData',
  264. },
  265. {
  266. title: '交货人',
  267. field: 'delivery',
  268. },
  269. {
  270. title: '交货人联系方式',
  271. field: 'deliveryPhone',
  272. },
  273. {
  274. title: '交货方式',
  275. field: 'deliveryWay',
  276. },
  277. {
  278. title: '备注',
  279. field: 'remark',
  280. },
  281. {
  282. width: 110,
  283. title: '操作',
  284. action: true,
  285. plugins: [{
  286. icon: 'el-icon-edit',
  287. name: '查看',
  288. audit: '',
  289. event: {
  290. click: (item : any) => {
  291. (this as any).openEdit(item)
  292. }
  293. }
  294. }, {
  295. name: '接单',
  296. event: {
  297. click: (item : any) => (this as any).getOrder(item)
  298. }
  299. }]
  300. }
  301. ]
  302. }
  303. },
  304. }
  305. created() {
  306. this.timer = setInterval(() => {
  307. this.getDataList()
  308. }, 500)
  309. }
  310. // 工具栏方法
  311. clickHandle(e : any) {
  312. console.log(e);
  313. }
  314. // 保存新增
  315. doSave() {
  316. // (this.$refs.product as any).setShow(true)
  317. (this as any).$refs.bill.$refs.billForm.validate().then(() => {
  318. let query = (this as any).$refs.bill.$refs.billForm.getValue();
  319. // query.suborderList = [] // 子表单数据
  320. query.status = 0; // 默认未接单
  321. api.saveList(query, 'supplyTaskOrder').then((res : any) => {
  322. if (res.code === 200) {
  323. this.$message({
  324. type: 'success',
  325. message: '提交成功!'
  326. });
  327. this.getDataList();
  328. (this.$refs.bill as any).showTab = 'all';
  329. (this.$refs.bill as any).setBillFormValue({});
  330. } else this.failHandle(res)
  331. })
  332. })
  333. }
  334. // 保存修改
  335. orderTaking() {
  336. let query : any = (this as any).$refs.bill.$refs.billForm.getValue();
  337. api.updateList(query, 'supplyTaskOrder').then((res : any) => {
  338. if (res.code === 200) {
  339. this.$message({
  340. type: 'success',
  341. message: '保存成功!'
  342. });
  343. this.getDataList();
  344. (this.$refs.bill as any).showTab = 'all';
  345. (this.$refs.bill as any).setBillFormValue({});
  346. } else this.failHandle(res)
  347. })
  348. }
  349. getDataList() {
  350. if (!this.$refs.bill) {
  351. if (this.timeNum > 5) {
  352. clearInterval(this.timer)
  353. }
  354. this.timeNum++;
  355. return
  356. }
  357. clearInterval(this.timer)
  358. // submitState: 提交状态
  359. this.getPageList({}, 'all'); // 综合数据
  360. // recycleBin
  361. this.getPageList({ submitState: 0 }, 'draftsBox'); // 草稿箱数据
  362. this.getPageList({ submitState: 1 }, 'smt'); // 已提交数据
  363. }
  364. // 获取分页数据
  365. getPageList(query : any, type : any) {
  366. api.pageList(query, 'supplyTaskOrder').then((res : any) => {
  367. if (res.code === 200) {
  368. (this.$refs.bill as any).setTabTableValue(type, res.data.records);
  369. let page = {
  370. pageNo: res.data.current, //当前页
  371. pageSize: res.data.size, //每页条数
  372. total: res.data.total //总条数
  373. };
  374. (this.$refs.bill as any).setTablePage(type, page)
  375. } else this.failHandle(res)
  376. })
  377. }
  378. // 打开新增
  379. onAdd(e : any) {
  380. console.log(e);
  381. // this.orderType = '新增';
  382. (this.$refs.bill as any).setBillFormValue({}); // 设置单据表单数据
  383. (this.$refs.bill as any).showTab = 'bill';
  384. }
  385. // 打开编辑
  386. openEdit(e : any) {
  387. console.log(e);
  388. e = e.row ? e.row : e;
  389. // this.orderType = '编辑';
  390. (this.$refs.bill as any).setBillFormValue(e); // 设置单据表单数据
  391. (this.$refs.bill as any).showTab = 'bill';
  392. }
  393. // 搜索
  394. search(parames : any) {
  395. let query = parames.value
  396. if (parames.type === 'draftsBox') query.submitState = 0 // 草稿箱数据
  397. if (parames.type === 'smt') query.submitState = 1 // 草稿箱数据
  398. this.getPageList(query, parames.type) // 获取分页数据
  399. }
  400. // 接单
  401. getOrder(item : any) {
  402. api.ordersaccepting({ ids: item.id }, 'supplyTaskOrder').then((res : any) => {
  403. if (res.code === 200) {
  404. // 是否跳转销售订单 this.$router.push()
  405. this.getDataList();
  406. this.$message({
  407. type: 'success',
  408. message: '接单成功!'
  409. });
  410. } else this.failHandle(res)
  411. })
  412. }
  413. resert(parames : any) {
  414. console.log('重置回传参数', parames);
  415. }
  416. // 工具栏接单
  417. onOrder(n : string) {
  418. console.log(n + ':工具栏执行操作onOrder')
  419. }
  420. // 运行错误
  421. failHandle(err : any) {
  422. let msg = err.msg ? err.msg : '运行错误!';
  423. this.$message.error(msg)
  424. }
  425. }
  426. </script>