index.vue 11 KB

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