index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <template>
  2. <div>
  3. <div class="i-layout-page-header">
  4. <PageHeader class="product_tabs" title="会员卡" hidden-breadcrumb></PageHeader>
  5. </div>
  6. <Card :bordered="false" dis-hover class="ivu-mt">
  7. <Form ref="tableFrom" :model="tableFrom" :label-width="labelWidth" :label-position="labelPosition"
  8. @submit.native.prevent>
  9. <Row type="flex">
  10. <Col v-bind="grid">
  11. <Button v-auth="['admin-store-classes-add']" type="primary" icon="md-add"
  12. @click="add">添加班次</Button>
  13. </Col>
  14. </Row>
  15. </Form>
  16. <Table :columns="columns1" :data="tableList" ref="table" class="mt25" :loading="loading" highlight-row
  17. no-userFrom-text="暂无数据" no-filtered-userFrom-text="暂无筛选结果">
  18. <template slot-scope="{ row, index }" slot="groupname">
  19. {{row.checkin_option.groupname}}
  20. </template>
  21. <!-- workdays -->
  22. <template slot-scope="{ row, index }" slot="workdays">
  23. <el-tag v-for="witem in row.checkin_option.checkindate[0].workdays">{{witem | showWd}}</el-tag>
  24. </template>
  25. <template slot-scope="{ row, index }" slot="status">
  26. <Icon type="md-checkmark" v-if="row.status === 1" color="#0092DC" size="14" />
  27. <Icon type="md-close" v-else color="#ed5565" size="14" />
  28. </template>
  29. <template slot-scope="{ row, index }" slot="time">
  30. <!-- <span> {{row.add_time | formatDate}}</span> -->
  31. <div v-for="time in row.time" style="margin-top: 10px;">
  32. <span>{{time.work_sec| showTime}} </span> - <span>{{time.off_work_sec | showTime}}</span>
  33. </div>
  34. </template>
  35. <template slot-scope="{ row, index }" slot="add_time">
  36. <span> {{row.add_time | formatDate}}</span>
  37. </template>
  38. <template slot-scope="{ row, index }" slot="action">
  39. <!-- <a @click="couponSend(row)">编辑</a>
  40. <Divider type="vertical" /> -->
  41. <a @click="couponDel(row,'删除会员卡',index)">删除</a>
  42. </template>
  43. </Table>
  44. <div class="acea-row row-right page">
  45. <Page :total="total" :current="tableFrom.page" show-elevator show-total @on-change="pageChange"
  46. :page-size="tableFrom.limit" />
  47. </div>
  48. </Card>
  49. <!--表单编辑-->
  50. <edit-from :FromData="FromData" @changeType="changeType" ref="edits"></edit-from>
  51. </div>
  52. </template>
  53. <script>
  54. import {
  55. mapState
  56. } from 'vuex';
  57. import {
  58. checkGroupList,
  59. checkRuleList,
  60. getClasses
  61. } from '@/api/store';
  62. import editFrom from '@/components/from/from';
  63. import {
  64. formatDate
  65. } from '@/utils/validate';
  66. import Setting from "@/setting";
  67. export default {
  68. name: 'storeCoupon',
  69. filters: {
  70. formatDate(time) {
  71. if (time !== 0) {
  72. let date = new Date(time * 1000);
  73. return formatDate(date, 'yyyy-MM-dd hh:mm');
  74. }
  75. },
  76. showWd(day) {
  77. let str = ''
  78. if(day) {
  79. switch (day*1){
  80. case 1:
  81. str = '星期一'
  82. break;
  83. case 2:
  84. str = '星期二'
  85. break;
  86. case 3:
  87. str = '星期三'
  88. break;
  89. case 4:
  90. str = '星期四'
  91. break;
  92. case 5:
  93. str = '星期五'
  94. break;
  95. case 6:
  96. str = '星期六'
  97. break;
  98. case 0:
  99. str = '星期日'
  100. break;
  101. default:
  102. break;
  103. }
  104. }
  105. return str
  106. }
  107. },
  108. components: {
  109. editFrom
  110. },
  111. filters: {
  112. showTime(seconds) {
  113. if(seconds ) {
  114. var hours = Math.floor(seconds / 3600);
  115. var minutes = Math.floor((seconds % 3600) / 60);
  116. return (hours > 9?hours: '0' + hours ) + ": " + (minutes>9?minutes: '0'+ minutes)
  117. }
  118. }
  119. },
  120. data() {
  121. return {
  122. roterPre: Setting.roterPre,
  123. grid: {
  124. xl: 7,
  125. lg: 7,
  126. md: 12,
  127. sm: 24,
  128. xs: 24
  129. },
  130. loading: false,
  131. columns1: [{
  132. title: 'ID',
  133. key: 'id',
  134. width: 80
  135. },
  136. {
  137. title: '班次名称',
  138. key: 'name',
  139. minWidth: 150
  140. },
  141. {
  142. title: '打卡奖励',
  143. key: 'price',
  144. minWidth: 80
  145. },
  146. {
  147. title: '打卡时段',
  148. slot: 'time',
  149. minWidth: 100
  150. },
  151. {
  152. title: '添加时间',
  153. key: 'create_time',
  154. minWidth: 100
  155. },
  156. // {
  157. // title: '折扣',
  158. // key: 'discount_ratio',
  159. // minWidth: 100
  160. // },
  161. {
  162. title: '操作',
  163. slot: 'action',
  164. fixed: 'right',
  165. minWidth: 170
  166. }
  167. ],
  168. tableFrom: {
  169. page: 1,
  170. limit: 15
  171. },
  172. tableList: [],
  173. total: 0,
  174. FromData: null
  175. }
  176. },
  177. created() {
  178. this.getList();
  179. },
  180. computed: {
  181. ...mapState('admin/layout', [
  182. 'isMobile'
  183. ]),
  184. labelWidth() {
  185. return this.isMobile ? undefined : 90;
  186. },
  187. labelPosition() {
  188. return this.isMobile ? 'top' : 'left';
  189. }
  190. },
  191. methods: {
  192. // 失效
  193. couponInvalid(row, tit, num) {
  194. let delfromData = {
  195. title: tit,
  196. num: num,
  197. url: `marketing/coupon/status/${row.id}`,
  198. method: 'PUT',
  199. ids: ''
  200. };
  201. this.$modalSure(delfromData).then((res) => {
  202. this.$Message.success(res.msg);
  203. this.getList();
  204. }).catch(res => {
  205. this.$Message.error(res.msg);
  206. });
  207. },
  208. // 发布
  209. couponSend(row) {
  210. // this.$modalForm(VipEditApi(row.id)).then(() => this.getList());
  211. this.$router.push({
  212. path: this.roterPre + "/store/checkRule/create"
  213. });
  214. },
  215. // 删除
  216. couponDel(row, tit, num) {
  217. let delfromData = {
  218. title: tit,
  219. url: `membership/deleteCard/${row.id}`,
  220. method: 'DELETE',
  221. ids: ''
  222. };
  223. this.$modalSure(delfromData).then((res) => {
  224. this.$Message.success(res.msg);
  225. this.tableList.splice(num, 1)
  226. }).catch(res => {
  227. this.$Message.error(res.msg);
  228. });
  229. },
  230. // 列表
  231. getList() {
  232. this.loading = true;
  233. getClasses(this.tableFrom).then(async res => {
  234. let data = res.data
  235. this.tableList = data.list;
  236. this.total = res.data.count;
  237. this.loading = false;
  238. }).catch(res => {
  239. this.loading = false;
  240. this.$Message.error(res.msg);
  241. });
  242. },
  243. pageChange(index) {
  244. this.tableFrom.page = index;
  245. this.getList();
  246. },
  247. changeType(data) {
  248. this.type = data;
  249. },
  250. // 添加
  251. add() {
  252. // this.$modalForm(couponCreateApi()).then(() => this.getList());
  253. this.$router.push({
  254. path: this.roterPre + "/store/classes/create"
  255. });
  256. // this.addType(0);
  257. },
  258. addType(type) {
  259. couponCreateApi(type).then(async res => {
  260. if (res.data.status === false) {
  261. return this.$authLapse(res.data);
  262. }
  263. // console.log()
  264. console.log(res.data, 'res.data');
  265. this.FromData = res.data;
  266. this.$refs.edits.modals = true;
  267. }).catch(res => {
  268. this.$Message.error(res.msg);
  269. })
  270. },
  271. // 编辑
  272. edit(row) {
  273. this.$modalForm(couponEditeApi(row.id)).then(() => this.getList());
  274. },
  275. // 表格搜索
  276. userSearchs() {
  277. this.tableFrom.page = 1;
  278. this.getList();
  279. },
  280. // 修改成功
  281. submitFail() {
  282. this.getList();
  283. }
  284. }
  285. }
  286. </script>
  287. <style scoped>
  288. .ivu-col:nth-of-type(1) .ivu-form-item .ivu-form-item-label {
  289. width: 80px !important;
  290. }
  291. .ivu-col:nth-of-type(1) .ivu-form-item .ivu-form-item-content {
  292. margin-left: 80px !important;
  293. }
  294. </style>