rebate_list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  1. <template>
  2. <div class="app-container">
  3. <div class="screen-container">
  4. <el-form
  5. ref="screenForm"
  6. :model="screenForm"
  7. size="small"
  8. label-position="left"
  9. >
  10. <el-row :gutter="20">
  11. <el-col :xs="24" :ms="6" :lg="6">
  12. <el-form-item label="" prop="mainName">
  13. <el-input
  14. v-model="screenForm.mainName"
  15. placeholder="返利品类"
  16. size="small"
  17. ></el-input>
  18. </el-form-item>
  19. </el-col>
  20. <el-col :xs="24" :ms="6" :lg="6">
  21. <el-form-item label="" prop="saleTypeCode">
  22. <el-input
  23. v-model="screenForm.saleTypeCode"
  24. placeholder="销售类型编码"
  25. size="small"
  26. ></el-input>
  27. </el-form-item>
  28. </el-col>
  29. <el-col :xs="24" :ms="6" :lg="6">
  30. <el-form-item label="" prop="saleTypeName">
  31. <el-input
  32. v-model="screenForm.saleTypeName"
  33. placeholder="销售类型名称"
  34. size="small"
  35. ></el-input>
  36. </el-form-item>
  37. </el-col>
  38. <el-col :xs="24" :ms="6" :lg="6">
  39. <el-form-item prop="status">
  40. <el-select
  41. v-model="screenForm.status"
  42. placeholder="请选择"
  43. size="small"
  44. >
  45. <el-option
  46. v-for="item in options"
  47. :key="item.value"
  48. :label="item.label"
  49. :value="item.value"
  50. >
  51. </el-option>
  52. </el-select>
  53. </el-form-item>
  54. </el-col>
  55. <el-col :xs="24" :ms="18" :lg="18">
  56. <el-form-item>
  57. <el-button
  58. type="primary"
  59. size="small"
  60. @click="(dialogVisible = true), (type = 1), getDictList()"
  61. >新增</el-button
  62. >
  63. <el-button type="primary" size="small" @click="submitScreenForm"
  64. >查询</el-button
  65. >
  66. <el-button type="primary" size="small" @click="resetScreenForm"
  67. >重置</el-button
  68. >
  69. </el-form-item>
  70. </el-col>
  71. </el-row>
  72. </el-form>
  73. </div>
  74. <div class="mymain-container">
  75. <el-table
  76. v-loading="listLoading"
  77. :data="dataList"
  78. element-loading-text="Loading"
  79. border
  80. fit
  81. highlight-current-row
  82. stripe
  83. >
  84. <el-table-column type="selection" width="55" align="center">
  85. </el-table-column>
  86. <template v-for="col in columns">
  87. <el-table-column
  88. align="center"
  89. :label="col.lable"
  90. :prop="col.prop"
  91. :min-width="col.widht"
  92. show-overflow-tooltip
  93. v-if="col.prop == 'status'"
  94. >
  95. <template slot-scope="scope">
  96. <el-switch
  97. v-model="scope.row.status"
  98. @change="handleSwitch($event,scope.row.walletRebateId)"
  99. :active-text="scope.row.status ? '已启用' : '已禁用'"
  100. >
  101. </el-switch>
  102. </template>
  103. </el-table-column>
  104. <el-table-column
  105. v-else
  106. align="center"
  107. :label="col.lable"
  108. :prop="col.prop"
  109. :min-width="col.widht"
  110. show-overflow-tooltip
  111. >
  112. </el-table-column>
  113. </template>
  114. <el-table-column
  115. align="center"
  116. fixed="right"
  117. label="操作"
  118. min-width="160"
  119. >
  120. <template slot-scope="scope">
  121. <el-button type="text" size="small" @click="hanleDateil(scope.row)"
  122. >查看</el-button
  123. >
  124. <el-button type="text" size="small" @click="hanleEdit(scope.row)"
  125. >编辑</el-button
  126. >
  127. <!-- <el-button type="text" size="small">编辑</el-button> -->
  128. </template>
  129. </el-table-column>
  130. </el-table>
  131. <!-- 分页 -->
  132. <div class="fr">
  133. <el-pagination
  134. @size-change="handleSizeChange"
  135. @current-change="handleCurrentChange"
  136. :current-page="currentPage"
  137. :page-sizes="[10, 20, 30, 50]"
  138. :page-size="10"
  139. layout="total, sizes, prev, pager, next, jumper"
  140. :total="listTotal"
  141. >
  142. </el-pagination>
  143. </div>
  144. </div>
  145. <div>
  146. <el-dialog :visible.sync="dialogVisible" width="50%" @close="hanelclose" title="返利类型">
  147. <el-form
  148. :model="dialogForm"
  149. ref="dialogForm"
  150. label-width="120px"
  151. :inline="false"
  152. size="normal"
  153. >
  154. <el-form-item label="返利使用钱包" prop="name">
  155. <el-input
  156. v-model="dialogForm.name"
  157. :readonly="type == 3"
  158. ></el-input>
  159. </el-form-item>
  160. <el-form-item label="销售类型编码" prop="saleTypeCode">
  161. <el-select
  162. v-model="dialogForm.saleTypeCode"
  163. :disabled="type == 3"
  164. @change="handleChange"
  165. placeholder="请选择类型编码"
  166. >
  167. <el-option
  168. v-for="item in typeList"
  169. :key="item.sysDictId"
  170. :label="item.dictValue"
  171. :value="item.saleCode"
  172. >
  173. </el-option>
  174. </el-select>
  175. </el-form-item>
  176. <el-form-item label="销售类型名称" prop="saleTypeName">
  177. <el-input
  178. v-model="dialogForm.saleTypeName"
  179. :readonly="type == 3"
  180. ></el-input>
  181. </el-form-item>
  182. <el-form-item label="产品使用品类" prop="mainName">
  183. <el-input v-model="dialogForm.mainName" :readonly="type == 3" ></el-input>
  184. <!-- <el-select v-model="dialogForm.mainId" @change="handleChange">
  185. <el-option
  186. v-for="(item, index) in productList"
  187. :key="index"
  188. :label="item.productCategoryName"
  189. :value="item.productCategoryNumber"
  190. >
  191. </el-option>
  192. </el-select> -->
  193. </el-form-item>
  194. <el-form-item label="返利折扣比例" prop="rabateRate">
  195. <el-input
  196. placeholder="例如:0.1=1折"
  197. :readonly="type == 3"
  198. v-model="dialogForm.rabateRate"
  199. ></el-input>
  200. </el-form-item>
  201. <el-form-item label="状态" prop="status">
  202. <el-switch
  203. v-model="dialogForm.status"
  204. :disabled="type == 3"
  205. :active-value="true"
  206. :inactive-value="false"
  207. :active-text="dialogForm.status ? '启用' : ''"
  208. >
  209. </el-switch>
  210. </el-form-item>
  211. </el-form>
  212. <template v-if="type !== 3">
  213. <span slot="footer" class="dialog-footer">
  214. <el-button @click="hanleCancel">取 消</el-button>
  215. <el-button type="primary" @click="handelInfo">确 定</el-button>
  216. </span>
  217. </template>
  218. </el-dialog>
  219. </div>
  220. </div>
  221. </template>
  222. <script>
  223. import Mixin from "@/mixin/index";
  224. import Pagination from "@/components/Pagination";
  225. import {
  226. addWallet,
  227. getDictList,
  228. getTypeList,
  229. updateWallet,
  230. getWalletList,
  231. getWalletDetail,
  232. getProductList
  233. } from "@/api/policy_list";
  234. export default {
  235. mixins: [Mixin],
  236. data() {
  237. return {
  238. type: 0, // 0 1
  239. screenForm: {
  240. mainName: "",
  241. saleTypeCode: "",
  242. saleTypeName: "",
  243. status: "",
  244. },
  245. dialogForm: {
  246. name: "",
  247. mainName: "",
  248. mainId: "",
  249. saleTypeCode: "",
  250. saleTypeName: "",
  251. rabateRate: "",
  252. status: "",
  253. },
  254. dataList: [],
  255. columns: [
  256. {
  257. prop: "saleTypeCode",
  258. lable: "销售类型编码",
  259. widht: 160,
  260. },
  261. {
  262. prop: "saleTypeName",
  263. lable: "销售类型名称",
  264. widht: 160,
  265. },
  266. {
  267. prop: "name",
  268. lable: "返利使用钱包",
  269. widht: 160,
  270. },
  271. {
  272. prop: "rebateRate",
  273. lable: "返利折扣比例",
  274. widht: 160,
  275. },
  276. {
  277. prop: "status",
  278. lable: "状态",
  279. widht: 160,
  280. },
  281. {
  282. prop: "createBy",
  283. lable: "创建人",
  284. widht: 160,
  285. },
  286. {
  287. prop: "createTime",
  288. lable: "创建时间",
  289. widht: 160,
  290. },
  291. {
  292. prop: "updateBy",
  293. lable: "更新人",
  294. widht: 160,
  295. },
  296. {
  297. prop: "updateTime",
  298. lable: "更新时间",
  299. widht: 160,
  300. },
  301. ],
  302. options: [
  303. {
  304. value: "",
  305. label: "状态",
  306. },
  307. {
  308. value: true,
  309. label: "已启用",
  310. },
  311. {
  312. value: false,
  313. label: "已停用",
  314. },
  315. ],
  316. dictListData: [],
  317. typeList: [],
  318. };
  319. },
  320. methods: {
  321. getList() {
  322. this.listLoading = true;
  323. const params = {
  324. pageNum: this.currentPage,
  325. pageSize: this.pageSize,
  326. mainName: this.screenForm.mainName,
  327. saleTypeCode: this.screenForm.saleTypeCode,
  328. saleTypeName: this.screenForm.saleTypeName,
  329. status: this.screenForm.status,
  330. };
  331. getWalletList(params).then((res) => {
  332. this.dataList = res.data.records;
  333. this.listTotal = res.data.total;
  334. this.listLoading = false;
  335. });
  336. getProductList({
  337. productCategoryName: "",
  338. productCategoryNumber: "",
  339. }).then((res) => {
  340. this.productList = res.data;
  341. });
  342. },
  343. handleChange(e){
  344. console.log(e,this.typeList);
  345. this.typeList.find(k=>{
  346. if (e == k.saleCode) {
  347. this.dialogForm.saleTypeName = k.saleName
  348. this.dialogForm.mainId = k.mainId
  349. this.dialogForm.mainName = k.mainName
  350. }
  351. })
  352. },
  353. handleSwitch(e,walletRebateId){
  354. updateWallet({
  355. walletRebateId,
  356. status: e,
  357. }).then((res) => {
  358. this.$successMsg("状态已更改");
  359. // this.hanleReset();
  360. });
  361. },
  362. hanleEdit(item) {
  363. console.log(item);
  364. this.dialogForm = {
  365. adminCompanyId: item.adminCompanyId,
  366. mainId: item.mainId,
  367. mainName: item.mainName,
  368. name: item.name,
  369. rabateRate: item.rabateRate,
  370. rabateSort: item.rabateSort,
  371. saleTypeCode: item.saleTypeCode,
  372. saleTypeId: item.saleTypeId,
  373. saleTypeName: item.saleTypeName,
  374. status: item.status,
  375. walletRebateId: item.walletRebateId,
  376. };
  377. this.getDictList();
  378. this.dialogVisible = true;
  379. },
  380. getDictList() {
  381. getDictList({
  382. sysDictEnum: "PRODUCT_TYPE",
  383. }).then((res) => {
  384. console.log(res);
  385. this.dictListData = res.data;
  386. });
  387. const params = {
  388. pageNum: 1,
  389. pageSize: 10,
  390. saleCode: "",
  391. saleName: "",
  392. status: "",
  393. };
  394. getTypeList(params).then((res) => {
  395. this.typeList = res.data.records;
  396. });
  397. },
  398. hanleDateil(item) {
  399. this.type = 3;
  400. this.dialogVisible = true;
  401. this.dialogForm = {
  402. ...item,
  403. };
  404. },
  405. hanelclose() {
  406. this.type = "";
  407. this.hanleReset();
  408. },
  409. handelInfo() {
  410. if (this.type) {
  411. this.hanleScreen(this.dialogForm.mainId);
  412. const params = {
  413. ...this.dialogForm,
  414. };
  415. addWallet(params).then((res) => {
  416. console.log(res);
  417. this.$successMsg("添加成功");
  418. this.hanleReset();
  419. });
  420. } else {
  421. const upParams = {
  422. ...this.dialogForm,
  423. };
  424. updateWallet(upParams).then((res) => {
  425. this.$successMsg("修改成功");
  426. this.hanleReset();
  427. });
  428. }
  429. },
  430. hanleReset() {
  431. this.dialogForm = {
  432. name: "",
  433. mainId: "",
  434. mainName: "",
  435. saleTypeCode: "",
  436. saleTypeName: "",
  437. rabateRate: "",
  438. status: true,
  439. };
  440. // this.$refs.dialogForm.resetFields()
  441. this.dialogVisible = false;
  442. this.getList();
  443. },
  444. hanleCancel() {
  445. this.hanleReset();
  446. this.dialogVisible = false;
  447. },
  448. hanleScreen(code) {
  449. this.dictListData.find((k) => {
  450. if (k.dictCode == code) {
  451. this.dialogForm.mainId = k.dictCode;
  452. this.dialogForm.mainName = k.dictValue;
  453. return;
  454. }
  455. });
  456. },
  457. },
  458. components: {
  459. Pagination,
  460. },
  461. };
  462. </script>
  463. <style scoped>
  464. .el-switch.is-disabled {
  465. opacity: inherit;
  466. }
  467. ::v-deep .el-select{
  468. width: 100%;
  469. }
  470. </style>