index.vue 11 KB

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