wallet_list.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <template>
  2. <div class="app-container">
  3. <!-- 筛选条件 -->
  4. <div>
  5. <el-form
  6. ref="searchForm"
  7. :model="searchForm"
  8. label-width="100px"
  9. size="small"
  10. label-position="left"
  11. >
  12. <el-row :gutter="20">
  13. <el-col :xs="24" :sm="12" :lg="6">
  14. <el-form-item label="名称" prop="walletName">
  15. <el-input
  16. v-model="searchForm.walletName"
  17. placeholder="请输入"
  18. ></el-input>
  19. </el-form-item>
  20. </el-col>
  21. <el-col :xs="24" :sm="12" :lg="6">
  22. <el-form-item label="产品大类" prop="mainId">
  23. <el-select
  24. class="selectStyle"
  25. filterable
  26. v-model="searchForm.mainId"
  27. placeholder="名称"
  28. >
  29. <el-option
  30. v-for="item in categoryList"
  31. :key="item.productCategoryNumber"
  32. :label="item.productCategoryName"
  33. :value="item.productCategoryNumber"
  34. >
  35. </el-option>
  36. </el-select>
  37. </el-form-item>
  38. </el-col>
  39. <el-col :xs="24" :sm="24" :lg="12" class="tr">
  40. <el-form-item label="">
  41. <el-button size="small" @click="clearFn">清空</el-button>
  42. <el-button size="small" type="primary" @click="searchFn"
  43. >搜索</el-button
  44. >
  45. </el-form-item>
  46. </el-col>
  47. </el-row>
  48. </el-form>
  49. </div>
  50. <!-- 按钮 -->
  51. <div class="btn-group clearfix">
  52. <div class="fl">
  53. <el-button type="primary" v-if="false" size="small">更新</el-button>
  54. </div>
  55. <div class="fr">
  56. <el-button type="primary" size="small">导出</el-button>
  57. </div>
  58. </div>
  59. <!-- 列表 -->
  60. <div class="mymain-container">
  61. <div class="table">
  62. <el-table
  63. v-loading="listLoading"
  64. :data="dataList"
  65. element-loading-text="Loading"
  66. border
  67. fit
  68. highlight-current-row
  69. stripe
  70. >
  71. <el-table-column
  72. align="center"
  73. label="编码"
  74. prop="number"
  75. min-width="160"
  76. show-overflow-tooltip
  77. ></el-table-column>
  78. <el-table-column
  79. align="center"
  80. label="现金钱包名称"
  81. prop="name"
  82. min-width="160"
  83. show-overflow-tooltip
  84. ></el-table-column>
  85. <el-table-column
  86. align="center"
  87. label="对应产品大类"
  88. prop="mainName"
  89. min-width="160"
  90. show-overflow-tooltip
  91. ></el-table-column>
  92. <el-table-column
  93. align="center"
  94. label="操作"
  95. prop="caozuo"
  96. min-width="160"
  97. show-overflow-tooltip
  98. >
  99. <template slot-scope="scope"
  100. ><el-button
  101. type="text"
  102. class="textColor"
  103. v-if="$checkBtnRole('edit', $route.meta.roles)"
  104. @click="setFn(scope.row)"
  105. >设置</el-button
  106. >
  107. </template>
  108. </el-table-column>
  109. </el-table>
  110. </div>
  111. </div>
  112. <!-- 弹窗 -->
  113. <el-dialog
  114. title="钱包"
  115. :visible.sync="dialogForm"
  116. width="30%"
  117. :show-close="false"
  118. :close-on-click-modal="false"
  119. >
  120. <el-form ref="addForm" :model="addForm" label-width="120px">
  121. <el-form-item label="现金钱包名称" prop="customerId">
  122. <el-input disabled v-model="addForm.name"></el-input>
  123. </el-form-item>
  124. <el-form-item label="编码" prop="customerId">
  125. <el-input disabled v-model="addForm.number"></el-input>
  126. </el-form-item>
  127. <el-form-item label="对应产品大类" prop="customerId">
  128. <el-select
  129. class="selectStyle"
  130. v-model="addForm.mainId"
  131. placeholder="名称"
  132. >
  133. <el-option
  134. v-for="item in categoryList"
  135. :key="item.productCategoryNumber"
  136. :label="item.productCategoryName"
  137. :value="item.productCategoryNumber"
  138. >
  139. </el-option>
  140. </el-select>
  141. </el-form-item>
  142. <el-form-item label="折让钱包" prop="customerId">
  143. <el-radio-group v-model="addForm.isZr">
  144. <el-radio :label="true">是</el-radio>
  145. <el-radio :label="false">否</el-radio>
  146. </el-radio-group>
  147. </el-form-item>
  148. <el-form-item label="是否使用返利" prop="customerId">
  149. <el-radio-group v-model="addForm.isRebate">
  150. <el-radio :label="true">是</el-radio>
  151. <el-radio :label="false">否</el-radio>
  152. </el-radio-group>
  153. </el-form-item>
  154. </el-form>
  155. <div slot="footer" class="dialog-footer">
  156. <el-button @click="cancelFn">取 消</el-button>
  157. <el-button type="primary" @click="btnOK">确 定</el-button>
  158. </div>
  159. </el-dialog>
  160. </div>
  161. </template>
  162. <script>
  163. import {
  164. getWalletList,
  165. getProductCategory,
  166. getWalletBiandMain,
  167. getWalletDetail,
  168. } from "@/api/basic_data/wallet_list";
  169. export default {
  170. data() {
  171. return {
  172. listLoading: false, // 列表加载loading
  173. searchForm: {
  174. walletName: "",
  175. mainId: "",
  176. },
  177. listTotal: 0, // 列表总数
  178. dataList: [],
  179. dialogForm: false,
  180. categoryList: [],
  181. addForm: {
  182. id: "",
  183. isRebate: null,
  184. isZr: null,
  185. mainId: "",
  186. mainName: "",
  187. name: "",
  188. number: "",
  189. },
  190. walletId: null, //钱包ID
  191. };
  192. },
  193. created() {
  194. this.getDataList();
  195. this.getCategoryList();
  196. },
  197. methods: {
  198. //确定
  199. async btnOK() {
  200. console.log(this.addForm);
  201. console.log(this.categoryList);
  202. const res = this.categoryList.filter(
  203. (v) => v.productCategoryNumber == this.addForm.mainId
  204. );
  205. let data = {
  206. id: this.walletId,
  207. isRebate: this.addForm.isRebate,
  208. isZr: this.addForm.isZr,
  209. mainId: this.addForm.mainId,
  210. mainName: res[0].productCategoryName,
  211. };
  212. await getWalletBiandMain(data);
  213. this.addForm.isRebate = null;
  214. this.addForm.isZr = null;
  215. this.addForm.mainId = "";
  216. this.getDataList();
  217. this.$message.success("设置成功");
  218. this.dialogForm = false;
  219. },
  220. //取消
  221. cancelFn() {
  222. // this.addForm.isRebate = null;
  223. // this.addForm.isZr = null;
  224. // this.addForm.mainId = "";
  225. this.dialogForm = false;
  226. },
  227. //清空
  228. async clearFn() {
  229. await this.$refs.searchForm.resetFields();
  230. },
  231. //搜索
  232. searchFn() {
  233. this.getDataList({ ...this.searchForm });
  234. },
  235. //获取产品品类列表
  236. async getCategoryList() {
  237. const res = await getProductCategory();
  238. this.categoryList = res.data;
  239. },
  240. //设置产品大类
  241. async setFn(value) {
  242. console.log(value);
  243. this.walletId = value.id;
  244. // this.addForm.name = value.name;
  245. // this.addForm.number = value.number;
  246. let res = await getWalletDetail({ walletId: value.id });
  247. console.log(res);
  248. this.addForm.name = res.data.name;
  249. this.addForm.number = res.data.number;
  250. this.addForm.mainId = res.data.mainId;
  251. this.addForm.isRebate = res.data.isRebate;
  252. this.addForm.isZr = res.data.isZr;
  253. this.dialogForm = true;
  254. },
  255. //获取列表数据
  256. async getDataList(data) {
  257. const res = await getWalletList(data);
  258. this.dataList = res.data;
  259. },
  260. },
  261. };
  262. </script>
  263. <style lang="scss" scoped>
  264. .selectStyle {
  265. width: 100%;
  266. }
  267. </style>