index.vue 11 KB

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