index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  1. <template>
  2. <div>
  3. <basic-container v-show="!detailsOpen">
  4. <avue-crud :option="option" :search.sync="search" v-model="form" :table-loading="loading" :data="dataList"
  5. ref="crud" :key="key" @selection-change="selectionChange" @on-load="onLoad" @search-change="searchChange"
  6. @row-del="rowDel" @refresh-change="refreshChange"
  7. @resetColumn="resetColumnTwo('crud', 'option', 'optionList', 276)"
  8. @saveColumn="saveColumnTwo('crud', 'option', 'optionList', 276)" :page.sync="page"
  9. @row-update="rowUpdate">
  10. <template slot-scope="{type,size,row,index}" slot="menu" >
  11. <!--<el-button icon="el-icon-view" :size="size" :type="type" @click="check(row)">查看</el-button>-->
  12. <el-button type="text" size="small" :disabled="Number(row.sendTotalNum) == Number(row.goodsTotalNum)" @click="rowCell(row, index)">{{ row.$cellEdit ? '保存' : '修改' }}
  13. </el-button>
  14. <!--<el-button style="color: red" type="text" size="small" v-if="row.statusName == '已派工'" @click="shipRevokeWorkOrderfun(row, index)">撤销派工-->
  15. <!--</el-button>-->
  16. <!-- <el-button :disabled="row.statusName === '已派工'" :size="size" :type="type"
  17. @click="$refs.crud.rowDel(row, index)">删除
  18. </el-button> -->
  19. </template>
  20. <template slot="corpNameSearch">
  21. <crop-select v-model="search.corpId" corpType="KH" :refresh="false"></crop-select>
  22. </template>
  23. <template slot-scope="{type,size,row,$index}" slot="menuLeft">
  24. <!-- <el-button icon="el-icon-plus" type="primary" :size="size" @click="detailsOpen = true">新增</el-button>-->
  25. <!-- <el-button type="warning" icon="el-icon-download" size="small" @click="outExport">导出</el-button>-->
  26. <el-button type="success" icon="el-icon-finished" size="small" @click="dispatching"
  27. :disabled="selectionList.length <= 0">派工
  28. </el-button>
  29. <el-button type="success" icon="el-icon-finished" size="small" @click="shipRevokeWorkOrderfun"
  30. :disabled="!chexiaofun()">撤销派工
  31. </el-button>
  32. </template>
  33. </avue-crud>
  34. </basic-container>
  35. <!--<detailsPage v-if="detailsOpen" :onLoad="form" :detailData="detailData" @backToList="backToList"></detailsPage>-->
  36. </div>
  37. </template>
  38. <script>
  39. import {
  40. getList,
  41. remove,
  42. outboundWorkOrder,
  43. typeSave,
  44. generateWarehousing,
  45. shipRevokeWorkOrder
  46. } from "@/api/tirePartsMall/salesManagement/outboundTask";
  47. import da from "element-ui/src/locale/lang/da";
  48. import fa from "element-ui/src/locale/lang/fa";
  49. // import detailsPage from "./detailsPage"
  50. export default {
  51. name: "index",
  52. components: {
  53. // detailsPage
  54. },
  55. data() {
  56. return {
  57. detailsOpen: false,
  58. loading: false,
  59. search: { statusName:'待处理' },
  60. form: {},
  61. dataList: [],
  62. selectionList: [],
  63. detailData: {},
  64. page: {
  65. pageSize: 20,
  66. currentPage: 1,
  67. total: 0,
  68. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  69. },
  70. key: 0,
  71. option: {},
  72. optionList: {
  73. selection: true,
  74. viewBtn: false,
  75. editBtn: false,
  76. celBtn: true,
  77. delBtn: false,
  78. addBtn: false,
  79. menu: true,
  80. index: true,
  81. span: 8,
  82. border: true,
  83. height: "auto",
  84. searchMenuPosition: "right",
  85. align: "center",
  86. size: "small",
  87. menuWidth: 100,
  88. searchSpan: 8,
  89. searchIcon: true,
  90. searchIndex: 2,
  91. highlightCurrentRow: true,
  92. dialogWidth: "70%",
  93. summaryText: "合计",
  94. showSummary: true,
  95. sumColumnList: [ {
  96. name: 'goodsTotalNum',
  97. type: 'sum',
  98. decimals: 0
  99. }, {
  100. name: 'sendTotalNum',
  101. type: 'sum',
  102. decimals: 0
  103. },],
  104. column: [{
  105. label: '采购单号',
  106. prop: "ordNo",
  107. search: true,
  108. searchOrder:1,
  109. width: 140,
  110. overHidden: true,
  111. },{
  112. label: '单据编号',
  113. prop: "billno",
  114. search: true,
  115. searchOrder:1,
  116. width: 140,
  117. overHidden: true,
  118. }, {
  119. label: '状态',
  120. prop: "statusName",
  121. searchOrder:2,
  122. width: 100,
  123. search: true,
  124. type: 'select',
  125. overHidden: true,
  126. dicData: [{
  127. label: '待处理',
  128. value: '待处理'
  129. }, {
  130. label: '已派工',
  131. value: '已派工'
  132. }, {
  133. label: '未完成',
  134. value: '未完成'
  135. }, {
  136. label: '已完成',
  137. value: '已完成'
  138. }],
  139. change: ({ value }) => {
  140. console.log(value,133)
  141. // this.option.column[1].searchValue = value;
  142. },
  143. searchValue:'待处理',
  144. value:'待处理'
  145. }, {
  146. label: '业务对象',
  147. prop: "customerName",
  148. search: true,
  149. width: 140,
  150. type: 'select',
  151. overHidden: true,
  152. props: {
  153. label: 'cname',
  154. value: 'id'
  155. },
  156. dicUrl: '/api/blade-sales-part/corpsDesc/listAll?corpType=GYS',
  157. }
  158. // , {
  159. // label: "商品种类",
  160. // prop: "corpId",
  161. // width: 100,
  162. // overHidden: true,
  163. // }
  164. ,
  165. // {
  166. // label: '业务来源',
  167. // prop: "bsType",
  168. // width: 100,
  169. // overHidden: true,
  170. // },
  171. // {
  172. // label: '来源公司',
  173. // prop: "sourceCompanyName",
  174. // search: true,
  175. // width: 100,
  176. // overHidden: true,
  177. // type: 'select',
  178. // props: {
  179. // label: 'fullName',
  180. // value: 'fullName'
  181. // },
  182. // dicUrl: '/api/blade-system/dept/top-list'
  183. // },
  184. {
  185. label: '收货仓库',
  186. prop: "storageName",
  187. width: 100,
  188. search: true,
  189. overHidden: true,
  190. cell:false,
  191. type: 'select',
  192. props: {
  193. label: 'cname',
  194. value: 'cname'
  195. },
  196. dicUrl: '/api/blade-sales-part/storageDesc/listAll',
  197. },
  198. {
  199. label: '库管',
  200. prop: "stockClerkId",
  201. width: 100,
  202. cell:false,
  203. overHidden: true,
  204. type: 'select',
  205. props: {
  206. label: 'realName',
  207. value: 'id'
  208. },
  209. dicUrl: '/api/blade-user/stockClerkList',
  210. },
  211. {
  212. label: '收货地址',
  213. prop: "recAddress",
  214. width: 200,
  215. overHidden: true,
  216. },
  217. {
  218. label: '采购数量',
  219. prop: "goodsTotalNum",
  220. width: 100,
  221. overHidden: true,
  222. },
  223. {
  224. label: '收货数量',
  225. prop: "sendTotalNum",
  226. width: 100,
  227. overHidden: true,
  228. },
  229. {
  230. label: '联系人',
  231. prop: "contacts",
  232. width: 100,
  233. overHidden: true,
  234. }, {
  235. label: '电话',
  236. prop: "phone",
  237. width: 100,
  238. overHidden: true,
  239. }, {
  240. label: '备注',
  241. prop: "remarks",
  242. width: 200,
  243. cell:false,
  244. overHidden: true,
  245. }, {
  246. label: '业务日期',
  247. prop: "businesDate",
  248. searchProp: "businesDateList",
  249. type: "date",
  250. overHidden: true,
  251. search: true,
  252. width: 100,
  253. searchRange: true,
  254. searchDefaultTime: ["00:00:00", "23:59:59"],
  255. format: "yyyy-MM-dd",
  256. valueFormat: "yyyy-MM-dd HH:mm:ss"
  257. }]
  258. }
  259. }
  260. },
  261. async created() {
  262. this.option = await this.getColumnData(this.getColumnName(276), this.optionList);
  263. this.key++
  264. let i = 0;
  265. this.option.column.forEach(item => {
  266. if (item.search) i++
  267. })
  268. if (i % 3 !== 0) {
  269. const num = 3 - Number(i % 3)
  270. this.option.searchMenuSpan = num * 8;
  271. this.option.searchMenuPosition = "right";
  272. }
  273. this.option = await this.getColumnData(this.getColumnName(276), this.optionList);
  274. this.option.selectable = (row, index) => {
  275. return Number(row.sendTotalNum) !== Number(row.goodsTotalNum);
  276. }
  277. },
  278. methods: {
  279. // 撤销派工的数据判断
  280. chexiaofun(){
  281. let typefalse = false
  282. for(let item of this.selectionList) {
  283. if (item.statusName == '已派工') {
  284. typefalse = true
  285. }else {
  286. typefalse = false
  287. break;
  288. }
  289. }
  290. return typefalse
  291. },
  292. selectionChange(list) {
  293. console.log(list);
  294. this.selectionList = list
  295. },
  296. // 撤销派工
  297. shipRevokeWorkOrderfun(){
  298. this.$confirm('是否要撤销派工?', '提示', {
  299. confirmButtonText: '确定',
  300. cancelButtonText: '取消',
  301. type: 'warning'
  302. }).then(()=>{
  303. const data = []
  304. for(let i in this.selectionList) {
  305. data.push(this.selectionList[i].id)
  306. }
  307. shipRevokeWorkOrder(data.join(',')).then(res=>{
  308. this.$message({
  309. type: 'success',
  310. message: '撤销派工成功!'
  311. });
  312. this.onLoad(this.page)
  313. })
  314. })
  315. },
  316. dispatching() {
  317. this.$confirm('是否确认派工?', '提示', {
  318. confirmButtonText: '确定',
  319. cancelButtonText: '取消',
  320. type: 'warning'
  321. }).then(() => {
  322. let data = []
  323. for (let item of this.selectionList) {
  324. data.push(item.id)
  325. }
  326. this.loading = true; // Show the loading spinner
  327. generateWarehousing(data.join(',')).then(res => {
  328. this.$message({
  329. type: 'success',
  330. message: '生成成功!'
  331. });
  332. this.onLoad(this.page)
  333. }).finally(() => {
  334. this.loading = false; // Hide the loading spinner
  335. });
  336. })
  337. },
  338. check(row) {
  339. this.form = row
  340. this.detailsOpen = true
  341. },
  342. backToList(type) {
  343. this.form = {}
  344. this.detailsOpen = false
  345. if (type === 0) {
  346. this.detailData = {}
  347. }
  348. this.onLoad(this.page, this.search)
  349. },
  350. //列表更新
  351. rowUpdate(form, index, done) {
  352. console.log(form);
  353. typeSave(form).then(res => {
  354. this.$message({type: "success", message: form.id ? "修改成功!" : "新增成功!"});
  355. // this.page.currentPage = 1;
  356. // this.onLoad(this.page);
  357. //成功关闭此页面回到列表页
  358. // this.backToList()
  359. })
  360. done()
  361. },
  362. //刷新
  363. refreshChange() {
  364. this.onLoad(this.page, this.search)
  365. },
  366. rowCell(row,index){
  367. this.findObject(this.option.column, "storageName").cell = true
  368. this.findObject(this.optionList.column, "storageName").cell = true
  369. this.findObject(this.option.column, "stockClerkId").cell = true
  370. this.findObject(this.optionList.column, "stockClerkId").cell = true
  371. this.findObject(this.option.column, "remarks").cell = true
  372. this.findObject(this.optionList.column, "remarks").cell = true
  373. this.$refs.crud.rowCell(row, index)
  374. },
  375. rowDel(form, index) {
  376. this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
  377. confirmButtonText: '确定',
  378. cancelButtonText: '取消',
  379. type: 'warning'
  380. }).then(() => {
  381. remove(form.id).then(res => {
  382. this.$message({
  383. type: 'success',
  384. message: '删除成功!'
  385. });
  386. this.dataList.splice(index, 1);
  387. this.onLoad(this.page)
  388. })
  389. }).catch(() => {
  390. });
  391. },
  392. searchChange(params, done) {
  393. this.page.currentPage = 1
  394. done();
  395. this.onLoad(this.page, params)
  396. },
  397. onLoad(page, params = {}) {
  398. params = {
  399. // ...params,
  400. current: page.currentPage,
  401. size: page.pageSize,
  402. bizTypeName: "SHRW",
  403. ...Object.assign(params, this.search),
  404. customerName : params.$customerName
  405. }
  406. console.log(params);
  407. this.loading = true
  408. getList(params).then(res => {
  409. this.dataList = res.data.data.records
  410. this.page.total = res.data.data.total
  411. this.loading = false
  412. }).finally(() => {
  413. this.loading = false
  414. })
  415. },
  416. //自定义列保存
  417. async saveColumnTwo(ref, option, optionBack, code) {
  418. console.log(2132);
  419. /**
  420. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  421. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  422. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  423. */
  424. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  425. // this.option = await this.getColumnData(this.getColumnName(271), this.optionList);
  426. if (inSave) {
  427. this.$message.success("保存成功");
  428. //关闭窗口
  429. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  430. }
  431. },
  432. //自定义列重置
  433. async resetColumnTwo(ref, option, optionBack, code) {
  434. console.log(this[option]);
  435. console.log(this[optionBack]);
  436. this[option] = this[optionBack];
  437. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  438. if (inSave) {
  439. this.$message.success("重置成功");
  440. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  441. }
  442. this.option.selectable = (row, index) => {
  443. return Number(row.sendTotalNum) !== Number(row.goodsTotalNum);
  444. }
  445. }
  446. }
  447. }
  448. </script>
  449. <style scoped></style>