index.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. <template>
  2. <basic-container>
  3. <avue-crud :option="option"
  4. :table-loading="loading"
  5. :data="data"
  6. :page.sync="page"
  7. :permission="permissionList"
  8. :before-open="beforeOpen"
  9. v-model="form"
  10. ref="crud"
  11. @row-update="rowUpdate"
  12. @row-save="rowSave"
  13. @row-del="rowDel"
  14. @search-change="searchChange"
  15. @search-reset="searchReset"
  16. @selection-change="selectionChange"
  17. @current-change="currentChange"
  18. @size-change="sizeChange"
  19. @refresh-change="refreshChange"
  20. @on-load="onLoad">
  21. <template slot="menuLeft">
  22. <el-button type="primary"
  23. size="small"
  24. plain
  25. @click="handleDelete">确认发货
  26. </el-button>
  27. </template>
  28. <template slot-scope="scope" slot="menu">
  29. <el-button type="text"
  30. size="small"
  31. @click="goodsListView(scope.row.arrivalCode)">查看商品列表</el-button>
  32. </template>
  33. </avue-crud>
  34. <!-- 商品列表dialog -->
  35. <el-dialog title="商品列表"
  36. append-to-body
  37. :visible.sync="goodsBox"
  38. :before-close="handleClose"
  39. width="50%"
  40. heigh="30%">
  41. <avue-crud :option="appointGoodsOption"
  42. :table-loading="goodsLoading"
  43. :data="appointGoodsData"
  44. :page.sync="goodsPage"
  45. ref="grouponCrud"
  46. @on-load="goodsOnLoad">
  47. </avue-crud>
  48. </el-dialog>
  49. </basic-container>
  50. </template>
  51. <script>
  52. import {getList, getDetail, add, update, shipments, goodsList} from "@/api/distribution/storeappoint";
  53. import {mapGetters} from "vuex";
  54. import {appointGoodsOption} from "../../../option/mall/appointGoodsOption"
  55. export default {
  56. data() {
  57. return {
  58. form: {},
  59. query: {},
  60. loading: true,
  61. goodsBox: false,
  62. goodsLoading: false,
  63. page: {
  64. pageSize: 10,
  65. currentPage: 1,
  66. total: 0
  67. },
  68. arrivalCode: '',
  69. appointGoodsData: [],
  70. goodsPage: {
  71. pageSize: 10,
  72. currentPage: 1,
  73. total: 0
  74. },
  75. selectionList: [],
  76. appointGoodsOption,
  77. option: {
  78. selectable:(row,index)=>{
  79. return row.state === 0;
  80. },
  81. height:'auto',
  82. calcHeight: 30,
  83. addBtn: false,
  84. tip: false,
  85. searchShow: true,
  86. searchMenuSpan: 6,
  87. border: true,
  88. index: true,
  89. editBtn: false,
  90. viewBtn: true,
  91. delBtn: false,
  92. selection: true,
  93. searchSpan: 5,
  94. dialogClickModal: false,
  95. column: [
  96. {
  97. label: "供应商名称",
  98. labelWidth: 130,
  99. prop: "storeName",
  100. rules: [{
  101. required: true,
  102. message: "请输入供应商名称",
  103. trigger: "blur"
  104. }]
  105. },
  106. {
  107. label: "自提点名称",
  108. labelWidth: 130,
  109. prop: "takeName",
  110. rules: [{
  111. required: true,
  112. message: "请输入自提点名称",
  113. trigger: "blur"
  114. }]
  115. },
  116. {
  117. label: "自提点联系电话",
  118. labelWidth: 130,
  119. prop: "takeTel",
  120. rules: [{
  121. required: true,
  122. message: "自提点联系电话",
  123. trigger: "blur"
  124. }]
  125. },
  126. {
  127. label: "履约单状态",
  128. labelWidth: 130,
  129. prop: "state",
  130. searchLabelWidth: 130,
  131. type: "select",
  132. dicUrl: "/api/blade-system/dict-biz/dictionary?code=appoint_state",
  133. props: {
  134. label: "dictValue",
  135. value: "dictKey"
  136. },
  137. dataType: "number",
  138. search: true,
  139. hide: false,
  140. display: true,
  141. rules: [{
  142. required: true,
  143. message: "选择状态",
  144. trigger: "blur"
  145. }]
  146. },
  147. {
  148. label: "团购标题",
  149. labelWidth: 130,
  150. prop: "grouponName",
  151. rules: [{
  152. required: true,
  153. message: "请输入团购标题",
  154. trigger: "blur"
  155. }]
  156. },
  157. {
  158. label: "团购结束时间",
  159. labelWidth: 130,
  160. prop: "grouponEndTime",
  161. rules: [{
  162. required: true,
  163. message: "请输入团购结束时间",
  164. trigger: "blur"
  165. }]
  166. },
  167. ]
  168. },
  169. data: []
  170. };
  171. },
  172. computed: {
  173. ...mapGetters(["permission"]),
  174. permissionList() {
  175. return {
  176. // addBtn: this.vaildData(this.permission.appoint_add, false),
  177. // viewBtn: this.vaildData(this.permission.appoint_view, false),
  178. // delBtn: this.vaildData(this.permission.appoint_delete, false),
  179. // editBtn: this.vaildData(this.permission.appoint_edit, false)
  180. };
  181. },
  182. ids() {
  183. let ids = [];
  184. this.selectionList.forEach(ele => {
  185. ids.push(ele.id);
  186. });
  187. return ids.join(",");
  188. }
  189. },
  190. methods: {
  191. rowSave(row, done, loading) {
  192. add(row).then(() => {
  193. this.onLoad(this.page);
  194. this.$message({
  195. type: "success",
  196. message: "操作成功!"
  197. });
  198. done();
  199. }, error => {
  200. loading();
  201. window.console.log(error);
  202. });
  203. },
  204. rowUpdate(row, index, done, loading) {
  205. update(row).then(() => {
  206. this.onLoad(this.page);
  207. this.$message({
  208. type: "success",
  209. message: "操作成功!"
  210. });
  211. done();
  212. }, error => {
  213. loading();
  214. console.log(error);
  215. });
  216. },
  217. rowDel(row) {
  218. this.$confirm("确定将选择数据删除?", {
  219. confirmButtonText: "确定",
  220. cancelButtonText: "取消",
  221. type: "warning"
  222. })
  223. .then(() => {
  224. return remove(row.id);
  225. })
  226. .then(() => {
  227. this.onLoad(this.page);
  228. this.$message({
  229. type: "success",
  230. message: "操作成功!"
  231. });
  232. });
  233. },
  234. handleDelete() {
  235. if (this.selectionList.length === 0) {
  236. this.$message.warning("请选择至少一条数据");
  237. return;
  238. }
  239. this.$confirm("确定将选择的履约单进行发货么?", {
  240. confirmButtonText: "确定",
  241. cancelButtonText: "取消",
  242. type: "warning"
  243. })
  244. .then(() => {
  245. return shipments(this.ids);
  246. })
  247. .then(() => {
  248. this.onLoad(this.page);
  249. this.$message({
  250. type: "success",
  251. message: "操作成功!"
  252. });
  253. this.$refs.crud.toggleSelection();
  254. });
  255. },
  256. beforeOpen(done, type) {
  257. if (["edit", "view"].includes(type)) {
  258. getDetail(this.form.id).then(res => {
  259. this.form = res.data.data;
  260. });
  261. }
  262. done();
  263. },
  264. searchReset() {
  265. this.query = {};
  266. this.onLoad(this.page);
  267. },
  268. searchChange(params, done) {
  269. this.query = params;
  270. this.page.currentPage = 1;
  271. this.onLoad(this.page, params);
  272. done();
  273. },
  274. selectionChange(list) {
  275. this.selectionList = list;
  276. },
  277. selectionClear() {
  278. this.selectionList = [];
  279. this.$refs.crud.toggleSelection();
  280. },
  281. currentChange(currentPage){
  282. this.page.currentPage = currentPage;
  283. },
  284. sizeChange(pageSize){
  285. this.page.pageSize = pageSize;
  286. },
  287. refreshChange() {
  288. this.onLoad(this.page, this.query);
  289. },
  290. onLoad(page, params = {}) {
  291. this.loading = true;
  292. getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  293. const data = res.data.data;
  294. this.page.total = data.total;
  295. this.data = data.records;
  296. this.loading = false;
  297. this.selectionClear();
  298. });
  299. },
  300. goodsListView(arrivalCode) {
  301. this.arrivalCode = arrivalCode;
  302. this.goodsOnLoad(this.goodsPage)
  303. this.goodsBox = true;
  304. },
  305. handleClose() {
  306. this.goodsBox = false;
  307. },
  308. goodsOnLoad(page){
  309. console.log(this.arrivalCode, '------arrivalCode---------');
  310. this.goodsLoading = true;
  311. goodsList(page.currentPage, page.pageSize, this.arrivalCode).then(res => {
  312. const data = res.data.data;
  313. this.page.total = data.total;
  314. this.appointGoodsData = data.records;
  315. this.goodsLoading = false;
  316. this.selectionClear();
  317. });
  318. }
  319. }
  320. };
  321. </script>
  322. <style>
  323. </style>