index.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <template>
  2. <div>
  3. <Card :bordered="false" dis-hover class="mt15 ivu-mt" :padding="0">
  4. <div class="new_card_pd">
  5. <!-- 查询条件 -->
  6. <Form ref="tableFrom" inline :model="tableFrom" :label-width="labelWidth"
  7. :label-position="labelPosition" @submit.native.prevent>
  8. <!-- <FormItem label="是否删除:" label-for="is_show">
  9. <Select v-model="tableFrom.is_del" placeholder="请选择" clearable @on-change="userSearchs"
  10. class="input-add">
  11. <Option :value="0">正常</Option>
  12. <Option :value="1">已删除</Option>
  13. </Select>
  14. </FormItem> -->
  15. <FormItem label="项目名称:" label-for="coupon_title">
  16. <Input v-model="tableFrom.key" placeholder="请输入服务项目名称名称" @on-search="userSearchs"
  17. class="input-add mr14" />
  18. <Button type="primary" @click="orderSearch()" class="mr14">查询</Button>
  19. </FormItem>
  20. </Form>
  21. </div>
  22. </Card>
  23. <div class="i-layout-page-header">
  24. <PageHeader class="product_tabs" title="服务项目" hidden-breadcrumb></PageHeader>
  25. </div>
  26. <Card :bordered="false" dis-hover class="ivu-mt">
  27. <Form ref="tableFrom" :model="tableFrom" :label-width="labelWidth" :label-position="labelPosition"
  28. @submit.native.prevent>
  29. <Row type="flex">
  30. <Col v-bind="grid">
  31. <Button v-auth="['admin-marketing-serve-add']" type="primary" icon="md-add"
  32. @click="add">添加服务项目</Button>
  33. </Col>
  34. </Row>
  35. </Form>
  36. <Table :columns="columns1" :data="tableList" ref="table" class="mt25" :loading="loading" highlight-row
  37. no-userFrom-text="暂无数据" no-filtered-userFrom-text="暂无筛选结果">
  38. <template slot-scope="{ row }" slot="coupon_price">
  39. <span v-if="row.coupon_type==1">{{row.coupon_price}}元</span>
  40. <span
  41. v-if="row.coupon_type==2">{{parseFloat(row.coupon_price)/10}}折({{row.coupon_price.toString().split(".")[0]}}%)</span>
  42. </template>
  43. <!-- <template slot-scope="{ row, index }" slot="status">
  44. <Icon type="md-checkmark" v-if="row.status === 1" color="#0092DC" size="14" />
  45. <Icon type="md-close" v-else color="#ed5565" size="14" />
  46. </template> -->
  47. <template slot-scope="{ row, index }" slot="is_show">
  48. <span> {{row.is_show == 1 ?'显示': '隐藏'}}</span>
  49. </template>
  50. <template slot-scope="{ row, index }" slot="price">
  51. <span> {{row.product.price }}</span>
  52. </template>
  53. <template slot-scope="{ row, index }" slot="add_time">
  54. <span> {{row.add_time }}</span>
  55. </template>
  56. <template slot-scope="{ row, index }" slot="status">
  57. <i-switch v-model="row.is_display" :value="row.is_display" :true-value="1" :false-value="0"
  58. @on-change="changeSwitch(row)" size="large">
  59. <span slot="open">显示</span>
  60. <span slot="close">隐藏</span>
  61. </i-switch>
  62. </template>
  63. <template slot-scope="{ row, index }" slot="action">
  64. <!-- <a @click="bind(row)">绑定项目</a>
  65. <Divider type="vertical" /> -->
  66. <a @click="couponSend(row)">编辑</a>
  67. <Divider type="vertical" />
  68. <a @click="couponDel(row,'删除服务项目',index)">删除</a>
  69. </template>
  70. </Table>
  71. <div class="acea-row row-right page">
  72. <Page :total="total" :current="tableFrom.page" show-elevator show-total @on-change="pageChange"
  73. :page-size="tableFrom.limit" />
  74. </div>
  75. </Card>
  76. <!--表单编辑-->
  77. <edit-from :FromData="FromData" @changeType="changeType" ref="edits"></edit-from>
  78. </div>
  79. </template>
  80. <script>
  81. import {
  82. mapState
  83. } from 'vuex';
  84. import {
  85. couponEditeApi,
  86. couponSendApi,
  87. ServeItemListApi,
  88. VipDeleteApi,
  89. serveEditApi,
  90. serveDelApi,
  91. createServeProduct
  92. } from '@/api/marketing';
  93. import editFrom from '@/components/from/from';
  94. import {
  95. formatDate
  96. } from '@/utils/validate';
  97. import Setting from "@/setting";
  98. export default {
  99. name: 'storeCoupon',
  100. filters: {
  101. formatDate(time) {
  102. if (time !== 0) {
  103. let date = new Date(time * 1000);
  104. return formatDate(date, 'yyyy-MM-dd hh:mm');
  105. }
  106. }
  107. },
  108. components: {
  109. editFrom
  110. },
  111. data() {
  112. return {
  113. roterPre: Setting.roterPre,
  114. grid: {
  115. xl: 7,
  116. lg: 7,
  117. md: 12,
  118. sm: 24,
  119. xs: 24
  120. },
  121. loading: false,
  122. columns1: [{
  123. title: 'ID',
  124. key: 'id',
  125. width: 80
  126. },
  127. {
  128. title: '服务项目',
  129. key: 'store_name',
  130. minWidth: 150
  131. },
  132. {
  133. title: '价格',
  134. slot: 'price',
  135. minWidth: 80
  136. },
  137. // {
  138. // title: '手工费',
  139. // key: 'craft_price',
  140. // minWidth: 100
  141. // },
  142. // {
  143. // title: '销售提成',
  144. // key: 'sales_commissions',
  145. // minWidth: 100
  146. // },
  147. // {
  148. // title: '上级提成百分比',
  149. // key: 'superior_commission',
  150. // minWidth: 100
  151. // },
  152. {
  153. title: '库存',
  154. key: 'repertory',
  155. minWidth: 100
  156. },
  157. {
  158. title: '前端显示',
  159. slot: 'status',
  160. minWidth: 100
  161. },
  162. {
  163. title: '操作',
  164. slot: 'action',
  165. fixed: 'right',
  166. minWidth: 170
  167. }
  168. ],
  169. tableFrom: {
  170. is_show: 1,
  171. field_key: '',
  172. page: 1,
  173. limit: 15,
  174. is_del: 0,
  175. service_card_id: 0
  176. },
  177. tableList: [],
  178. total: 0,
  179. FromData: null
  180. }
  181. },
  182. created() {
  183. this.getList();
  184. },
  185. computed: {
  186. ...mapState('admin/layout', [
  187. 'isMobile'
  188. ]),
  189. labelWidth() {
  190. return this.isMobile ? undefined : 90;
  191. },
  192. labelPosition() {
  193. return this.isMobile ? 'top' : 'left';
  194. }
  195. },
  196. methods: {
  197. changeSwitch(row) {
  198. //
  199. console.log(row)
  200. createServeProduct(row.id, row)
  201. .then((res) => {
  202. this.$Message.success(res.msg);
  203. })
  204. .catch((err) => {
  205. this.$Message.error(err.msg);
  206. });
  207. },
  208. //绑定项目
  209. bind(row) {
  210. this.$router.push({
  211. path: this.roterPre + "/marketing/serve/bind?id=" + row.id
  212. });
  213. },
  214. // 失效
  215. couponInvalid(row, tit, num) {
  216. let delfromData = {
  217. title: tit,
  218. num: num,
  219. url: `marketing/coupon/status/${row.id}`,
  220. method: 'PUT',
  221. ids: ''
  222. };
  223. this.$modalSure(delfromData).then((res) => {
  224. this.$Message.success(res.msg);
  225. this.getList();
  226. }).catch(res => {
  227. this.$Message.error(res.msg);
  228. });
  229. },
  230. // 发布
  231. couponSend(row) {
  232. this.$router.push({
  233. path: this.roterPre + "/marketing/serve_item/create?id=" + row.id + '&craft_price=' + row
  234. .craft_price + '&performance_value=' + row.performance_value + '&product_id=' + row
  235. .product_id + '&repertory=' + row.repertory + '&sales_commissions=' + row
  236. .sales_commissions + '&slider_image=' + row.slider_image + '&store_name=' + row
  237. .store_name + '&superior_commission=' + row.superior_commission + '&is_display=' + row.is_display
  238. });
  239. console.log(row);
  240. },
  241. // 删除
  242. couponDel(row, tit, num) {
  243. let delfromData = {
  244. title: tit,
  245. url: `service/productDelete/${row.id}`,
  246. method: 'DELETE',
  247. ids: ''
  248. };
  249. this.$modalSure(delfromData).then((res) => {
  250. this.$Message.success(res.msg);
  251. this.tableList.splice(num, 1)
  252. }).catch(res => {
  253. this.$Message.error(res.msg);
  254. });
  255. },
  256. // 列表
  257. getList() {
  258. this.loading = true;
  259. ServeItemListApi(this.tableFrom).then(async res => {
  260. let data = res.data
  261. this.tableList = data.list;
  262. this.total = res.data.count;
  263. this.loading = false;
  264. }).catch(res => {
  265. this.loading = false;
  266. this.$Message.error(res.msg);
  267. });
  268. },
  269. pageChange(index) {
  270. this.tableFrom.page = index;
  271. this.getList();
  272. },
  273. changeType(data) {
  274. this.type = data;
  275. },
  276. // 添加
  277. add() {
  278. this.$router.push({
  279. path: this.roterPre + "/marketing/serve_item/create"
  280. });
  281. // this.addType(0);
  282. },
  283. // 编辑
  284. edit(row) {
  285. this.$modalForm(couponEditeApi(row.id)).then(() => this.getList());
  286. },
  287. // 表格搜索
  288. userSearchs() {
  289. this.tableFrom.page = 1;
  290. this.getList();
  291. },
  292. // 修改成功
  293. submitFail() {
  294. this.getList();
  295. },
  296. orderSearch() {
  297. this.tableFrom.page = 1;
  298. this.getList();
  299. }
  300. }
  301. }
  302. </script>
  303. <style scoped>
  304. .ivu-col:nth-of-type(1) .ivu-form-item .ivu-form-item-label {
  305. width: 80px !important;
  306. }
  307. .ivu-col:nth-of-type(1) .ivu-form-item .ivu-form-item-content {
  308. margin-left: 80px !important;
  309. }
  310. </style>