detail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <template>
  2. <div class="app-container">
  3. <div class="filter-container">
  4. <div class="filter-control">
  5. <span>优惠月份:</span>
  6. <el-date-picker
  7. v-model="time"
  8. type="monthrange"
  9. range-separator="至"
  10. start-placeholder="开始月份"
  11. end-placeholder="结束月份"
  12. />
  13. </div>
  14. <div class="filter-control">
  15. <el-button type="primary">新增优惠券</el-button>
  16. </div>
  17. </div>
  18. <el-card class="box-card">
  19. <el-form :model="form" label-width="100px">
  20. <el-form-item label="优惠券:">
  21. <el-radio-group v-model="form.radio">
  22. <el-radio :label="0">活动券</el-radio>
  23. <el-radio :label="1">品类券</el-radio>
  24. <el-radio :label="3">店铺券</el-radio>
  25. </el-radio-group>
  26. <el-button class="delete_label" type="primary" size="mini">删除</el-button>
  27. </el-form-item>
  28. <el-form-item label="供应商" :hidden="form.radio === 3 ? false : true">
  29. <el-button type="text" :hidden="!hiddenItem" @click="findShopList()">选择供应商</el-button>
  30. <el-table :data="shopData" border :hidden="hiddenItem">
  31. <el-table-column prop="name" label="供应商名称" />
  32. <el-table-column prop="sname" label="供应商简称" width="150px" />
  33. <el-table-column prop="linkMan" label="联系人" />
  34. <el-table-column prop="contractMobile" label="手机号" width="120px">
  35. <template slot-scope="{ row }">
  36. {{ row.contractMobile ? row.contractMobile : '---' }}
  37. </template>
  38. </el-table-column>
  39. <el-table-column label="操作">
  40. <template slot-scope="{ row }">
  41. <el-button type="text" @click="deleteShop(row)">删除</el-button>
  42. </template>
  43. </el-table-column>
  44. </el-table>
  45. </el-form-item>
  46. <el-form-item label="优惠券金额:">
  47. <el-input style="width: 150px" size="mini" />
  48. </el-form-item>
  49. <el-form-item label="优惠条件:">
  50. <span>订单商品总额满</span><el-input style="width: 150px" size="mini" />
  51. </el-form-item>
  52. <el-form-item label="优惠商品:" :hidden="form.radio === 0 ? false : true">
  53. <el-radio-group v-model="form.productType">
  54. <el-radio :label="1">全商城商品</el-radio>
  55. <el-radio :label="2">指定商品</el-radio>
  56. </el-radio-group>
  57. </el-form-item>
  58. <el-form-item :hidden="form.productType === 2 && form.radio === 0 ? false : true">
  59. <template>
  60. <el-button @click="deleteProduct()">删除</el-button>
  61. <el-button type="primary" @click="productList()">添加</el-button>
  62. </template>
  63. <el-form-item :hidden="hiddenProduct">
  64. <el-table :data="productTable" border @select="handleSelect">
  65. <el-table-column type="selection" width="55" />
  66. <el-table-column property="mainImage" label="商品图片" width="150">
  67. <template slot-scope="{ row }">
  68. <el-popover
  69. placement="top-start"
  70. title=""
  71. width="180"
  72. trigger="hover"
  73. >
  74. <img :src="row.mainImage" alt="" style="width:150px;height:150px;">
  75. <img slot="reference" :src="row.mainImage" alt="" style="width:30px;height:30px;">
  76. </el-popover>
  77. </template>
  78. </el-table-column>
  79. <el-table-column property="productName" label="商品名称" width="150" />
  80. <el-table-column property="shopName" label="供应商" width="150" />
  81. <el-table-column property="sort" label="网站状态" width="150" />
  82. <el-table-column property="pcStatus" label="小程序状态" width="150" />
  83. <el-table-column property="appletsStatus" label="排序" width="150" />
  84. <el-table-column property="addTime" label="添加时间" />
  85. <el-table-column label="操作">
  86. <template>
  87. <el-button type="text">删除</el-button>
  88. </template>
  89. </el-table-column>
  90. </el-table>
  91. </el-form-item>
  92. </el-form-item>
  93. <el-form-item label="优惠品类:" :hidden="form.radio === 1 ? false : true">
  94. <template>
  95. <el-radio v-model="form.categoryType" label="">产品</el-radio>
  96. <el-radio v-model="form.categoryType" label="2">仪器</el-radio>
  97. </template>
  98. </el-form-item>
  99. </el-form>
  100. </el-card>
  101. <!-- 供应商弹框 -->
  102. <el-dialog title="选择供应商" :visible.sync="dialogTableVisible" width="50%">
  103. <div class="filter-container">
  104. <div class="filter-control">
  105. <span>供应商Id:</span>
  106. <el-input
  107. v-model="shopForm.shopId"
  108. placeholder="供应商Id"
  109. clearable
  110. />
  111. </div>
  112. <div class="filter-control">
  113. <span>供应商名称:</span>
  114. <el-input
  115. v-model="shopForm.name"
  116. placeholder="供应商名称"
  117. clearable
  118. />
  119. </div>
  120. <div class="filter-control">
  121. <span>供应商简称:</span>
  122. <el-input
  123. v-model="shopForm.sname"
  124. placeholder="供应商简称"
  125. clearable
  126. />
  127. </div>
  128. <div class="filter-control">
  129. <el-button type="primary" @click="findShopList()">搜索</el-button>
  130. </div>
  131. </div>
  132. <el-table ref="table" :data="shopTableData" height="350px" @select="handleSelect">
  133. <el-table-column type="selection" width="55" />
  134. <el-table-column property="shopId" label="供应商Id" width="150" />
  135. <el-table-column property="name" label="供应商名称" width="150" />
  136. <el-table-column property="sname" label="供应商简称" width="200">
  137. <template slot-scope="{ row }">
  138. {{ row.sname ? row.sname : '---' }}
  139. </template>
  140. </el-table-column>
  141. <el-table-column property="linkMan" label="联系人" />
  142. <el-table-column property="contractMobile" label="手机号">
  143. <template slot-scope="{ row }">
  144. {{ row.contractMobile ? row.contractMobile : '---' }}
  145. </template>
  146. </el-table-column>
  147. </el-table>
  148. <div slot="footer">
  149. <el-button type="primary" @click="pushShop()">确定</el-button>
  150. <el-button type="primary" @click="dialogTableVisible = false">取消</el-button>
  151. </div>
  152. <!-- 页码 -->
  153. <pagination
  154. :total="shopTotal"
  155. :page-sizes="[20, 30, 50, 100]"
  156. :page-size="20"
  157. :page.sync="shopForm.pageNum"
  158. :limit.sync="shopForm.pageSize"
  159. @pagination="findShopList"
  160. />
  161. </el-dialog>
  162. <!-- 商品弹框 -->
  163. <el-dialog title="选择供应商" :visible.sync="dialogProductVisible" width="50%">
  164. <div class="filter-container">
  165. <div class="filter-control">
  166. <span>商品Id:</span>
  167. <el-input
  168. v-model="productForm.productId"
  169. placeholder="商品Id"
  170. clearable
  171. />
  172. </div>
  173. <div class="filter-control">
  174. <span>商品名称:</span>
  175. <el-input
  176. v-model="productForm.name"
  177. placeholder="商品名称"
  178. clearable
  179. />
  180. </div>
  181. <div class="filter-control">
  182. <span>供应商:</span>
  183. <el-input
  184. v-model="productForm.shopName"
  185. placeholder="供应商"
  186. clearable
  187. />
  188. </div>
  189. <div class="filter-control">
  190. <el-button type="primary" @click="productList()">搜索</el-button>
  191. </div>
  192. </div>
  193. <el-table ref="table" :data="productTableData" height="350px" @select="handleSelect">
  194. <el-table-column type="selection" width="55" />
  195. <el-table-column property="productId" label="商品Id" width="150" />
  196. <el-table-column property="mainImage" label="商品图片" width="150">
  197. <template slot-scope="{ row }">
  198. <el-popover
  199. placement="top-start"
  200. title=""
  201. width="180"
  202. trigger="hover"
  203. >
  204. <img :src="row.mainImage" alt="" style="width:150px;height:150px;">
  205. <img slot="reference" :src="row.mainImage" alt="" style="width:30px;height:30px;">
  206. </el-popover>
  207. </template>
  208. </el-table-column>
  209. <el-table-column property="name" label="商品名称" width="200" />
  210. <el-table-column property="shopName" label="供应商" />
  211. </el-table>
  212. <div slot="footer">
  213. <el-button type="primary" @click="pushProduct()">确定</el-button>
  214. <el-button type="primary" @click="dialogTableVisible = false">取消</el-button>
  215. </div>
  216. <!-- 页码 -->
  217. <pagination
  218. :total="productTotal"
  219. :page-sizes="[20, 30, 50, 100]"
  220. :page-size="20"
  221. :page.sync="productForm.pageNum"
  222. :limit.sync="productForm.pageSize"
  223. @pagination="productList"
  224. />
  225. </el-dialog>
  226. </div>
  227. </template>
  228. <script>
  229. import { fetchFindShop, fetchProductList } from '@/api/member/coupon/detail'
  230. export default {
  231. name: 'MemberDetail',
  232. data() {
  233. return {
  234. time: '',
  235. form: {
  236. radio: 0,
  237. productType: '', // 优惠商品
  238. categoryType: '' // 优惠品类
  239. },
  240. shopData: [],
  241. hiddenItem: true,
  242. dialogTableVisible: false,
  243. shopForm: {
  244. shopId: '', // 供应商id
  245. name: '', // 供应商名称
  246. sname: '', // 供应商简称
  247. pageNum: 1,
  248. pageSize: 20
  249. },
  250. shopTotal: 0,
  251. rows: [],
  252. // 供应商列表
  253. shopTableData: [],
  254. // 商品列表
  255. dialogProductVisible: false,
  256. productForm: {
  257. productId: '', // 商品id
  258. name: '', // 商品名称
  259. shopName: '', // 供应商名称
  260. pageNum: 1,
  261. pageSize: 20
  262. },
  263. hiddenProduct: true,
  264. productTable: [],
  265. productTableData: [],
  266. productTotal: 0
  267. }
  268. },
  269. created() {
  270. },
  271. methods: {
  272. // 获取供应商列表
  273. async findShopList() {
  274. this.dialogTableVisible = true
  275. const res = await fetchFindShop(this.shopForm)
  276. this.shopTableData = res.data.results
  277. this.shopTotal = res.data.totalRecord
  278. },
  279. // 选择供应商
  280. handleSelect(selection, row) {
  281. this.$refs.table.clearSelection()
  282. this.$refs.table.toggleRowSelection(row)
  283. this.rows = row
  284. console.log('row', this.rows)
  285. },
  286. // 确认选择供应商
  287. pushShop() {
  288. this.shopData.push(this.rows)
  289. this.dialogTableVisible = false
  290. this.hiddenItem = false
  291. this.rows = []
  292. },
  293. // 清除供应商
  294. deleteShop() {
  295. this.hiddenItem = true
  296. this.shopData = []
  297. },
  298. // 商品列表
  299. async productList() {
  300. this.dialogProductVisible = true
  301. const res = await fetchProductList(this.productForm)
  302. this.productTableData = res.data.results
  303. this.productTotal = res.data.totalRecord
  304. },
  305. // 添加商品数据
  306. pushProduct() {
  307. this.productTable.push(this.rows)
  308. this.dialogProductVisible = false
  309. this.hiddenProduct = false
  310. this.rows = []
  311. },
  312. // 清除商品数据
  313. deleteProduct() {
  314. this.productTable = []
  315. this.hiddenProduct = true
  316. }
  317. }
  318. }
  319. </script>
  320. <style>
  321. .delete_label{
  322. margin-left: 50px;
  323. }
  324. </style>