index.vue 11 KB

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