index.vue 15 KB

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