appoint.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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.grouponId)">查看详情</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. @size-change="sizeAppointChange"
  47. @on-load="goodsOnLoad">
  48. <template slot="menuLeft">
  49. <el-button type="primary"
  50. size="small"
  51. plain
  52. @click="downLoadAppoint">下载详情
  53. </el-button>
  54. </template>
  55. <template slot-scope="scope" slot="menu">
  56. </template>
  57. </avue-crud>
  58. </el-dialog>
  59. </basic-container>
  60. </template>
  61. <script>
  62. import {getList, getDetail, add, update, shipments, shipmentsAll, appointStoreList} from "@/api/distribution/appoint";
  63. import {mapGetters} from "vuex";
  64. import {appointGoodsOption} from "../../option/mall/appointGoodsOption"
  65. import {getToken} from '@/util/auth';
  66. export default {
  67. data() {
  68. return {
  69. form: {},
  70. query: {},
  71. loading: true,
  72. goodsBox: false,
  73. goodsLoading: false,
  74. page: {
  75. pageSize: 10,
  76. currentPage: 1,
  77. total: 0
  78. },
  79. grouponId: 0,
  80. appointGoodsData: [],
  81. goodsPage: {
  82. pageSize: 10,
  83. currentPage: 1,
  84. total: 0
  85. },
  86. selectionList: [],
  87. appointGoodsOption,
  88. option: {
  89. height:'auto',
  90. calcHeight: 30,
  91. addBtn: false,
  92. tip: false,
  93. searchShow: true,
  94. searchMenuSpan: 6,
  95. border: true,
  96. index: true,
  97. editBtn: false,
  98. viewBtn: false,
  99. delBtn: false,
  100. selection: false,
  101. searchSpan: 5,
  102. dialogClickModal: false,
  103. column: [
  104. {
  105. label: "团购标题",
  106. labelWidth: 130,
  107. prop: "grouponName",
  108. rules: [{
  109. required: true,
  110. message: "请输入团购标题",
  111. trigger: "blur"
  112. }]
  113. },
  114. {
  115. label: "团购开始时间",
  116. labelWidth: 130,
  117. prop: "grouponStartTime",
  118. },
  119. {
  120. label: "履约单状态",
  121. labelWidth: 130,
  122. prop: "appointState",
  123. searchLabelWidth: 130,
  124. type: "select",
  125. dicUrl: "/api/blade-system/dict-biz/dictionary?code=appoint_state",
  126. props: {
  127. label: "dictValue",
  128. value: "dictKey"
  129. },
  130. dataType: "number",
  131. search: true,
  132. hide: false,
  133. display: true,
  134. rules: [{
  135. required: true,
  136. message: "选择状态",
  137. trigger: "blur"
  138. }]
  139. },
  140. ]
  141. },
  142. data: []
  143. };
  144. },
  145. computed: {
  146. ...mapGetters(["permission"]),
  147. permissionList() {
  148. return {
  149. // addBtn: this.vaildData(this.permission.appoint_add, false),
  150. // viewBtn: this.vaildData(this.permission.appoint_view, false),
  151. // delBtn: this.vaildData(this.permission.appoint_delete, false),
  152. // editBtn: this.vaildData(this.permission.appoint_edit, false)
  153. };
  154. },
  155. ids() {
  156. let ids = [];
  157. this.selectionList.forEach(ele => {
  158. ids.push(ele.id);
  159. });
  160. return ids.join(",");
  161. }
  162. },
  163. methods: {
  164. rowSave(row, done, loading) {
  165. add(row).then(() => {
  166. this.onLoad(this.page);
  167. this.$message({
  168. type: "success",
  169. message: "操作成功!"
  170. });
  171. done();
  172. }, error => {
  173. loading();
  174. window.console.log(error);
  175. });
  176. },
  177. downLoadAppoint(){
  178. window.open(`/api/distribution/appoint/exportAllAppointGoods?${this.website.tokenHeader}=${getToken()}&grouponId=${this.grouponId}`);
  179. },
  180. rowUpdate(row, index, done, loading) {
  181. update(row).then(() => {
  182. this.onLoad(this.page);
  183. this.$message({
  184. type: "success",
  185. message: "操作成功!"
  186. });
  187. done();
  188. }, error => {
  189. loading();
  190. console.log(error);
  191. });
  192. },
  193. rowDel(row) {
  194. this.$confirm("确定将选择数据删除?", {
  195. confirmButtonText: "确定",
  196. cancelButtonText: "取消",
  197. type: "warning"
  198. })
  199. .then(() => {
  200. return remove(row.id);
  201. })
  202. .then(() => {
  203. this.onLoad(this.page);
  204. this.$message({
  205. type: "success",
  206. message: "操作成功!"
  207. });
  208. });
  209. },
  210. shipments(id){
  211. this.$confirm("确定将改履约单进行发货么?", {
  212. confirmButtonText: "确定",
  213. cancelButtonText: "取消",
  214. type: "warning"
  215. })
  216. .then(() => {
  217. return shipments(id);
  218. })
  219. .then(() => {
  220. this.onLoad(this.page);
  221. this.$message({
  222. type: "success",
  223. message: "操作成功!"
  224. });
  225. this.goodsOnLoad(this.goodsPage)
  226. this.$refs.grouponCrud.toggleSelection();
  227. });
  228. },
  229. shipmnetsALl(grouponId){
  230. this.$confirm("确定将这个团的所有履约单进行发货么?", {
  231. confirmButtonText: "确定",
  232. cancelButtonText: "取消",
  233. type: "warning"
  234. })
  235. .then(() => {
  236. return shipmentsAll(grouponId);
  237. })
  238. .then(() => {
  239. this.onLoad(this.page);
  240. this.$message({
  241. type: "success",
  242. message: "操作成功!"
  243. });
  244. this.$refs.crud.toggleSelection();
  245. });
  246. },
  247. beforeOpen(done, type) {
  248. if (["edit", "view"].includes(type)) {
  249. getDetail(this.form.id).then(res => {
  250. this.form = res.data.data;
  251. });
  252. }
  253. done();
  254. },
  255. searchReset() {
  256. this.query = {};
  257. this.onLoad(this.page);
  258. },
  259. searchChange(params, done) {
  260. this.query = params;
  261. this.page.currentPage = 1;
  262. this.onLoad(this.page, params);
  263. done();
  264. },
  265. selectionChange(list) {
  266. this.selectionList = list;
  267. },
  268. selectionClear() {
  269. this.selectionList = [];
  270. this.$refs.crud.toggleSelection();
  271. },
  272. currentChange(currentPage){
  273. this.page.currentPage = currentPage;
  274. },
  275. sizeChange(pageSize){
  276. this.page.pageSize = pageSize;
  277. },
  278. sizeAppointChange(pageSize){
  279. this.goodsPage.pageSize = pageSize;
  280. },
  281. refreshChange() {
  282. this.onLoad(this.page, this.query);
  283. },
  284. onLoad(page, params = {}) {
  285. this.loading = true;
  286. getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  287. const data = res.data.data;
  288. this.page.total = data.total;
  289. this.data = data.records;
  290. this.loading = false;
  291. this.selectionClear();
  292. });
  293. },
  294. goodsListView(grouponId) {
  295. this.grouponId = grouponId;
  296. this.goodsPage = {
  297. pageSize: 10,
  298. currentPage: 1,
  299. total: 0
  300. }
  301. this.goodsOnLoad(this.goodsPage)
  302. this.goodsBox = true;
  303. },
  304. handleClose() {
  305. this.goodsBox = false;
  306. },
  307. goodsOnLoad(page){
  308. this.goodsLoading = true;
  309. appointStoreList(page.currentPage, page.pageSize, this.grouponId).then(res => {
  310. const data = res.data.data;
  311. this.goodsPage.total = data.total;
  312. this.appointGoodsData = data.records;
  313. this.goodsLoading = false;
  314. this.selectionClear();
  315. });
  316. }
  317. }
  318. };
  319. </script>
  320. <style>
  321. </style>