selftake.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  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="status" slot-scope="scope" >
  22. <el-tag v-if="scope.row.status === 1" type="success">{{scope.row.$status}}</el-tag>
  23. <el-tag v-if="scope.row.status === 0" type="danger">{{scope.row.$status}}</el-tag>
  24. </template>
  25. <template slot="menu" slot-scope="scope">
  26. <el-button v-if="scope.row.status == 0"
  27. type="text"
  28. size="small"
  29. @click="modifyState(scope.row, 1)"
  30. >启用</el-button>
  31. <el-button v-if="scope.row.status == 1"
  32. type="text"
  33. size="small"
  34. @click="modifyState(scope.row, 0)"
  35. >禁用
  36. </el-button>
  37. </template>
  38. </avue-crud>
  39. </basic-container>
  40. </template>
  41. <script>
  42. import {getList, getDetail, add, update, remove} from "@/api/groupon/selftake";
  43. import {mapGetters} from "vuex";
  44. import {getUsualLogs} from "../../api/logs";
  45. export default {
  46. data() {
  47. return {
  48. lo: 0.0,
  49. la: 0.0,
  50. address: '',
  51. form: {},
  52. query: {},
  53. loading: true,
  54. page: {
  55. pageSize: 10,
  56. currentPage: 1,
  57. total: 0
  58. },
  59. selectionList: [],
  60. option: {
  61. height:'auto',
  62. calcHeight: 30,
  63. tip: false,
  64. searchShow: true,
  65. searchMenuSpan: 6,
  66. border: true,
  67. index: true,
  68. viewBtn: true,
  69. delBtn: false,
  70. selection: true,
  71. dialogClickModal: false,
  72. column: [
  73. {
  74. label: "名称",
  75. prop: "name",
  76. search: true,
  77. labelWidth: 120,
  78. rules: [{
  79. required: true,
  80. message: "请输入自提点名字",
  81. trigger: "blur"
  82. }]
  83. },
  84. {
  85. label: "地址",
  86. prop: "addressTemp",
  87. labelWidth: 120,
  88. type: 'map',
  89. hide: true,
  90. rules: [{
  91. required: true,
  92. message: "请输入自提点地址",
  93. trigger: "blur"
  94. }],
  95. },
  96. {
  97. label: "地址",
  98. prop: "address",
  99. addDisplay: false,
  100. editDisplay: false,
  101. labelWidth: 120,
  102. },
  103. {
  104. label: "联系人",
  105. prop: "contactPerson",
  106. hide: true,
  107. labelWidth: 120,
  108. },
  109. {
  110. label: "联系电话",
  111. prop: "contactNumber",
  112. hide: true,
  113. labelWidth: 120,
  114. },
  115. {
  116. label: "营业开始时间",
  117. prop: "busStartTime",
  118. valueFormat: 'HH:mm:ss',
  119. labelWidth: 120,
  120. type: "time",
  121. pickerOptions:{
  122. start: '08:00',
  123. step: '00:15',
  124. end: '22:00'
  125. },
  126. rules: [{
  127. required: true,
  128. message: "请输入营业开始时间",
  129. trigger: "blur"
  130. }]
  131. },
  132. {
  133. label: "营业结束时间",
  134. prop: "busEndTime",
  135. valueFormat: 'HH:mm:ss',
  136. labelWidth: 120,
  137. type: "time",
  138. pickerOptions:{
  139. start: '08:00',
  140. step: '00:15',
  141. end: '22:00'
  142. },
  143. rules: [{
  144. required: true,
  145. message: "请输入营业结束时间",
  146. trigger: "blur"
  147. }]
  148. },
  149. {
  150. label: "状态",
  151. prop: "status",
  152. labelWidth: 120,
  153. rules: [{
  154. required: true,
  155. message: "请输入状态",
  156. trigger: "blur"
  157. }],
  158. search: true,
  159. slot:true,
  160. type: "select",
  161. dicUrl: "/api/blade-system/dict-biz/getEnumDict?enumName=StatusEnum",
  162. props: {
  163. label: "name",
  164. value: "value"
  165. },
  166. dataType: "number",
  167. },
  168. ]
  169. },
  170. data: []
  171. };
  172. },
  173. computed: {
  174. ...mapGetters(["permission"]),
  175. permissionList() {
  176. return {
  177. addBtn: this.vaildData(this.permission.selftake_add, false),
  178. viewBtn: this.vaildData(this.permission.selftake_view, false),
  179. delBtn: this.vaildData(this.permission.selftake_delete, false),
  180. editBtn: this.vaildData(this.permission.selftake_edit, false)
  181. };
  182. },
  183. ids() {
  184. let ids = [];
  185. this.selectionList.forEach(ele => {
  186. ids.push(ele.id);
  187. });
  188. return ids.join(",");
  189. }
  190. },
  191. methods: {
  192. rowSave(row, done, loading) {
  193. row.longitude = row.addressTemp[0];
  194. row.latitude = row.addressTemp[1];
  195. row.address = row.addressTemp[2];
  196. console.log(row)
  197. add(row).then(() => {
  198. this.onLoad(this.page);
  199. this.$message({
  200. type: "success",
  201. message: "操作成功!"
  202. });
  203. done();
  204. }, error => {
  205. loading();
  206. window.console.log(error);
  207. });
  208. },
  209. rowUpdate(row, index, done, loading) {
  210. row.longitude = row.addressTemp[0];
  211. row.latitude = row.addressTemp[1];
  212. row.address = row.addressTemp[2];
  213. update(row).then(() => {
  214. this.onLoad(this.page);
  215. this.$message({
  216. type: "success",
  217. message: "操作成功!"
  218. });
  219. done();
  220. }, error => {
  221. loading();
  222. console.log(error);
  223. });
  224. },
  225. rowDel(row) {
  226. this.$confirm("确定将选择数据删除?", {
  227. confirmButtonText: "确定",
  228. cancelButtonText: "取消",
  229. type: "warning"
  230. })
  231. .then(() => {
  232. return remove(row.id);
  233. })
  234. .then(() => {
  235. this.onLoad(this.page);
  236. this.$message({
  237. type: "success",
  238. message: "操作成功!"
  239. });
  240. });
  241. },
  242. handleDelete() {
  243. if (this.selectionList.length === 0) {
  244. this.$message.warning("请选择至少一条数据");
  245. return;
  246. }
  247. this.$confirm("确定将选择数据删除?", {
  248. confirmButtonText: "确定",
  249. cancelButtonText: "取消",
  250. type: "warning"
  251. })
  252. .then(() => {
  253. return remove(this.ids);
  254. })
  255. .then(() => {
  256. this.onLoad(this.page);
  257. this.$message({
  258. type: "success",
  259. message: "操作成功!"
  260. });
  261. this.$refs.crud.toggleSelection();
  262. });
  263. },
  264. beforeOpen(done, type) {
  265. if (["edit", "view"].includes(type)) {
  266. getDetail(this.form.id).then(res => {
  267. this.form = res.data.data;
  268. });
  269. }
  270. done();
  271. },
  272. searchReset() {
  273. this.query = {};
  274. this.onLoad(this.page);
  275. },
  276. searchChange(params, done) {
  277. this.query = params;
  278. this.page.currentPage = 1;
  279. this.onLoad(this.page, params);
  280. done();
  281. },
  282. selectionChange(list) {
  283. this.selectionList = list;
  284. },
  285. selectionClear() {
  286. this.selectionList = [];
  287. this.$refs.crud.toggleSelection();
  288. },
  289. currentChange(currentPage){
  290. this.page.currentPage = currentPage;
  291. },
  292. sizeChange(pageSize){
  293. this.page.pageSize = pageSize;
  294. },
  295. refreshChange() {
  296. this.onLoad(this.page, this.query);
  297. },
  298. onLoad(page, params = {}) {
  299. this.loading = true;
  300. this.query.isAdmin = "true";
  301. getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  302. const data = res.data.data;
  303. this.page.total = data.total;
  304. this.data = data.records;
  305. this.loading = false;
  306. this.selectionClear();
  307. });
  308. },
  309. modifyState(row, status) {
  310. let title = status === 0 ? '确定禁用?' : '确定启用?';
  311. this.$confirm(title, {
  312. confirmButtonText: "确定",
  313. cancelButtonText: "取消",
  314. type: "warning"
  315. }).then(() => {
  316. const loading = this.$loading({
  317. lock: true,
  318. text: '修改中,请稍等...',
  319. spinner: 'el-icon-loading',
  320. background: 'rgba(0, 0, 0, 0.7)'
  321. });
  322. row.status = status;
  323. update(row).then(() => {
  324. loading.close();
  325. this.onLoad(this.page);
  326. this.$message({
  327. type: "success",
  328. message: "操作成功!"
  329. });
  330. }, error => {
  331. loading.close();
  332. console.log(error);
  333. });
  334. })
  335. },
  336. }
  337. };
  338. </script>
  339. <style>
  340. </style>