index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  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. log:{
  26. request:{
  27. url:'/supply/supplyTaskOrderOperateLog/page',
  28. method:'GET'
  29. }
  30. },
  31. form: {
  32. attr: {
  33. size: 'medium',
  34. readonly: true,
  35. },
  36. columns: [
  37. [
  38. {
  39. span: 8,
  40. label: '机构名称',
  41. prop: 'organizationName',
  42. component: 'by-input',
  43. },
  44. {
  45. span: 8,
  46. label: '单据编号',
  47. prop: 'orderNumber',
  48. component: 'by-input',
  49. },
  50. {
  51. span: 8,
  52. label: '联系方式',
  53. prop: 'deliveryPhone',
  54. component: 'by-input',
  55. },
  56. {
  57. span: 8,
  58. label: '交货人',
  59. prop: 'delivery',
  60. component: 'by-input',
  61. },
  62. {
  63. span: 8,
  64. label: '交货时间',
  65. prop: 'deliveryData',
  66. component: 'by-input',
  67. },
  68. {
  69. span: 8,
  70. label: '交货地点',
  71. prop: 'deliveryAddress',
  72. component: 'by-input',
  73. },
  74. {
  75. span: 8,
  76. label: '交货方式',
  77. prop: 'deliveryWay',
  78. component: 'by-input',
  79. },
  80. ],
  81. [
  82. {
  83. span: 28,
  84. label: '备注',
  85. slot: true,
  86. prop: 'remark',
  87. component: 'by-input',
  88. compConfig: {
  89. attr: {
  90. size: 'mini',
  91. placeholder: '请输入备注',
  92. type: 'textarea'
  93. },
  94. }
  95. },
  96. ]
  97. ]
  98. },
  99. tableConfig: [
  100. {
  101. table: {
  102. attr: {
  103. size: 'mini',
  104. height: 500,
  105. align: 'center',
  106. readonly: true
  107. },
  108. columns:
  109. [{
  110. width: 300,
  111. title: '物料名称',
  112. field: 'materialName',
  113. },
  114. {
  115. width: 150,
  116. title: '单位',
  117. field: 'unit',
  118. },
  119. {
  120. width: 150,
  121. title: '数量',
  122. field: 'number',
  123. },
  124. {
  125. width: 150,
  126. title: '已交付数量',
  127. field: 'deliveryNumber',
  128. },
  129. {
  130. width: 150,
  131. title: '单价',
  132. field: 'unitPrice',
  133. },
  134. {
  135. width: 150,
  136. title: '实际金额',
  137. field: 'realityPrice',
  138. },
  139. {
  140. width: 150,
  141. title: '优惠金额',
  142. field: 'prePrice',
  143. },
  144. {
  145. width: 150,
  146. title: '合计金额',
  147. field: 'totalPrice',
  148. },
  149. ]
  150. }
  151. }
  152. ]
  153. },
  154. // 综合
  155. all: {
  156. search: {
  157. attr: {
  158. size: 'mini',
  159. },
  160. columns: [
  161. [
  162. {
  163. span: 6,
  164. label: '机构名称',
  165. prop: 'organizationName',
  166. component: 'by-input',
  167. compConfig: {
  168. attr: {
  169. placeholder: '请输入机构名称',
  170. clearable: true
  171. },
  172. },
  173. },
  174. {
  175. span: 6,
  176. label: '单据编号',
  177. prop: 'orderNumber',
  178. component: 'by-input',
  179. compConfig: {
  180. attr: {
  181. placeholder: '请输入单据编号',
  182. clearable: true
  183. }
  184. }
  185. },
  186. {
  187. span: 6,
  188. label: '交货时间',
  189. prop: 'deliveryData',
  190. component: 'by-date-picker',
  191. compConfig: {
  192. format: 'yyyy-MM-dd',
  193. type: 'datetime'
  194. }
  195. },
  196. {
  197. span: 6,
  198. label: '状态',
  199. prop: 'status',
  200. component: 'by-select',
  201. compConfig: {
  202. attr: {
  203. placeholder: '请选择状态',
  204. clearable: true,
  205. data: [{
  206. value: 0,
  207. label: '未接单'
  208. }, {
  209. value: 1,
  210. label: '已接单'
  211. }]
  212. }
  213. }
  214. },
  215. ],
  216. ]
  217. },
  218. tool: {
  219. tools: {
  220. // order: true,
  221. search: true,
  222. refresh: true
  223. }
  224. },
  225. table: {
  226. attr: {
  227. height: 620,
  228. size: 'mini',
  229. seq: true,
  230. align: 'left',
  231. checkbox: true
  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. // 工具栏方法
  312. clickHandle(e : any) {
  313. console.log('工具栏方法 ==> ', e);
  314. }
  315. // 保存新增
  316. doSave() {
  317. // (this.$refs.product as any).setShow(true)
  318. (this as any).$refs.bill.$refs.billForm.validate().then(() => {
  319. let query = (this as any).$refs.bill.$refs.billForm.getValue();
  320. // query.suborderList = [] // 子表单数据
  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. // 分页
  350. pagination(e : any) {
  351. let query : any = (this as any).$refs.bill.getSearchValue(e.type);
  352. query.pageNo = e.page.pageNum;
  353. query.pageSize = e.page.pageSize;
  354. query.submitState = 1;
  355. let loading = this.$loading({ target: '.main-container' });
  356. // query.submitState = 1; // 已提交状态
  357. api.pageList(query, 'supplyTaskOrder').then((res : any) => {
  358. if (res.code === 200) {
  359. (this.$refs.bill as any).setTabTableValue(e.type, res.data.records);
  360. loading.close()
  361. } else this.failHandle(res)
  362. })
  363. }
  364. getDataList() {
  365. if (!this.$refs.bill) {
  366. if (this.timeNum > 5) {
  367. clearInterval(this.timer)
  368. }
  369. this.timeNum++;
  370. return
  371. }
  372. clearInterval(this.timer)
  373. // submitState: 提交状态
  374. this.getPageList({}, 'all'); // 综合数据
  375. }
  376. // 获取分页数据
  377. getPageList(query : any, type : any) {
  378. query.submitState = 1; // 已提交状态
  379. api.pageList(query, 'supplyTaskOrder').then((res : any) => {
  380. if (res.code === 200) {
  381. (this.$refs.bill as any).setTabTableValue(type, res.data.records);
  382. let page = {
  383. pageNo: res.data.current, //当前页
  384. pageSize: res.data.size, //每页条数
  385. total: res.data.total //总条数
  386. };
  387. (this.$refs.bill as any).setTablePage(type, page)
  388. } else this.failHandle(res)
  389. })
  390. }
  391. // 打开新增
  392. onAdd(e : any) {
  393. console.log(e);
  394. (this.$refs.bill as any).setBillFormValue({}); // 设置单据表单数据
  395. (this.$refs.bill as any).showTab = 'bill';
  396. }
  397. // 打开编辑
  398. openEdit(e : any) {
  399. e = e.row ? e.row : e;
  400. let loading = this.$loading({ target: '.main-container' });
  401. api.single({ id: e.id }, 'supplyTaskOrder').then((res : any) => {
  402. if (res.code === 200) {
  403. let parentData = res.data ? res.data : e;
  404. (this.$refs.bill as any).setBillFormValue(parentData); // 设置单据表单数据
  405. (this.$refs.bill as any).setBillTableValue(parentData.suborderList, 0);// 设置第1张单据表格数据
  406. (this.$refs.bill as any).showTab = 'bill';
  407. loading.close();
  408. } else loading.close();
  409. });
  410. }
  411. // 搜索
  412. search(parames : any) {
  413. let loading = this.$loading({ target: '.main-container' });
  414. let query = parames.value
  415. if (parames.type === 'draftsBox') query.submitState = 0 // 草稿箱数据
  416. if (parames.type === 'smt') query.submitState = 1 // 草稿箱数据
  417. this.getPageList(query, parames.type) // 获取分页数据
  418. loading.close();
  419. }
  420. // 接单
  421. getOrder(item : any) {
  422. this.$confirm('确定接单吗', '注意', {
  423. confirmButtonText: '确定',
  424. cancelButtonText: '取消',
  425. type: 'warning',
  426. center: true
  427. }).then(() => {
  428. api.ordersaccepting({ ids: item.id }, 'supplyTaskOrder').then((res : any) => {
  429. if (res.code === 200) {
  430. this.getDataList();
  431. this.$message.success('接单成功!');
  432. this.$confirm('是否跳转销售订单', '提示', {
  433. confirmButtonText: '确定',
  434. cancelButtonText: '取消',
  435. }).then(() => {
  436. this.$router.push('/document/saleOrder');
  437. })
  438. } else this.failHandle(res)
  439. })
  440. }).catch(() => this.$message.info('已取消接单'));
  441. }
  442. // 刷新/重置
  443. resert(e : any) {
  444. let data : any = e.type ? e.type : e;
  445. (this as any).$refs.bill.$refs[data].clearSearch();
  446. if (data === 'all') this.getPageList({}, 'all'); // 综合数据
  447. }
  448. // 工具栏接单
  449. onOrder(n : string) {
  450. console.log(n + ':工具栏执行操作onOrder')
  451. }
  452. // 运行错误
  453. failHandle(err : any) {
  454. let msg = err.msg ? err.msg : '运行错误!';
  455. this.$message.error(msg)
  456. }
  457. }
  458. </script>