rebate_list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  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
  147. :visible.sync="dialogVisible"
  148. width="50%"
  149. @close="hanelclose"
  150. title="返利类型"
  151. >
  152. <el-form
  153. :model="dialogForm"
  154. ref="dialogForm"
  155. :rules="rules"
  156. label-width="120px"
  157. :inline="false"
  158. size="normal"
  159. >
  160. <el-form-item label="返利使用钱包" prop="name">
  161. <el-input
  162. v-model="dialogForm.name"
  163. :readonly="type == 3"
  164. ></el-input>
  165. </el-form-item>
  166. <el-form-item label="销售类型名称" prop="saleTypeName">
  167. <el-select
  168. v-model="dialogForm.saleTypeCode"
  169. :disabled="type == 3"
  170. @change="handleChange"
  171. placeholder="请选择销售类型编码"
  172. >
  173. <el-option
  174. v-for="item in typeList"
  175. :key="item.sysDictId"
  176. :label="item.saleName"
  177. :value="item.saleCode"
  178. >
  179. </el-option>
  180. </el-select>
  181. </el-form-item>
  182. <el-form-item label="销售类型编码" prop="saleTypeCode">
  183. <el-input
  184. v-model="dialogForm.saleTypeCode"
  185. :readonly="true"
  186. ></el-input>
  187. </el-form-item>
  188. <el-form-item label="产品使用品类" prop="mainName">
  189. <el-input v-model="dialogForm.mainName" :readonly="true"></el-input>
  190. </el-form-item>
  191. <el-form-item label="返利折扣比例" prop="rebateRate">
  192. <el-input
  193. type="number"
  194. placeholder="例如0.1=1折"
  195. :readonly="type == 3"
  196. @change="handleNumber"
  197. v-model.number="dialogForm.rebateRate"
  198. ></el-input>
  199. </el-form-item>
  200. <el-form-item label="状态" prop="status">
  201. <el-switch
  202. v-model="dialogForm.status"
  203. :disabled="type == 3"
  204. :active-value="true"
  205. :inactive-value="false"
  206. :active-text="dialogForm.status ? '启用' : ''"
  207. >
  208. </el-switch>
  209. </el-form-item>
  210. </el-form>
  211. <template v-if="type !== 3">
  212. <span slot="footer" class="dialog-footer">
  213. <el-button @click="hanleCancel">取 消</el-button>
  214. <el-button type="primary" @click="handelInfo">确 定</el-button>
  215. </span>
  216. </template>
  217. </el-dialog>
  218. </div>
  219. </div>
  220. </template>
  221. <script>
  222. import Mixin from "@/mixin/index";
  223. import Pagination from "@/components/Pagination";
  224. import {
  225. addWallet,
  226. getDictList,
  227. getTypeList,
  228. updateWallet,
  229. getWalletList,
  230. getWalletDetail,
  231. getProductList,
  232. } from "@/api/policy_list";
  233. export default {
  234. mixins: [Mixin],
  235. data() {
  236. return {
  237. type: 0, // 0 1
  238. screenForm: {
  239. mainName: "",
  240. saleTypeCode: "",
  241. saleTypeName: "",
  242. status: "",
  243. },
  244. dialogForm: {
  245. name: "",
  246. mainName: "",
  247. mainId: "",
  248. saleTypeCode: "",
  249. saleTypeName: "",
  250. rebateRate: "",
  251. status: "",
  252. },
  253. dataList: [],
  254. columns: [
  255. {
  256. prop: "saleTypeCode",
  257. lable: "销售类型编码",
  258. widht: 160,
  259. },
  260. {
  261. prop: "saleTypeName",
  262. lable: "销售类型名称",
  263. widht: 160,
  264. },
  265. {
  266. prop: "mainName",
  267. lable: "产品大类",
  268. widht: 160,
  269. },
  270. {
  271. prop: "name",
  272. lable: "返利类型",
  273. widht: 160,
  274. },
  275. {
  276. prop: "rebateRate",
  277. lable: "返利折扣比例",
  278. widht: 160,
  279. },
  280. {
  281. prop: "status",
  282. lable: "状态",
  283. widht: 160,
  284. },
  285. {
  286. prop: "createBy",
  287. lable: "创建人",
  288. widht: 160,
  289. },
  290. {
  291. prop: "createTime",
  292. lable: "创建时间",
  293. widht: 160,
  294. },
  295. {
  296. prop: "updateBy",
  297. lable: "更新人",
  298. widht: 160,
  299. },
  300. {
  301. prop: "updateTime",
  302. lable: "更新时间",
  303. widht: 160,
  304. },
  305. ],
  306. options: [
  307. {
  308. value: "",
  309. label: "全部",
  310. },
  311. {
  312. value: 1,
  313. label: "已启用",
  314. },
  315. {
  316. value: 0,
  317. label: "已停用",
  318. },
  319. ],
  320. dictListData: [],
  321. typeList: [],
  322. rules: {
  323. name: [{ required: true, message: "请输入名称", trigger: "blur" }],
  324. saleTypeCode: [
  325. { required: true, message: "请选择编码", trigger: "blur" },
  326. ],
  327. rebateRate: [
  328. { required: true, message: "请输入比例", trigger: "blur" },
  329. ],
  330. },
  331. };
  332. },
  333. methods: {
  334. getList() {
  335. this.listLoading = true;
  336. const params = {
  337. pageNum: this.currentPage,
  338. pageSize: this.pageSize,
  339. mainName: this.screenForm.mainName,
  340. saleTypeCode: this.screenForm.saleTypeCode,
  341. saleTypeName: this.screenForm.saleTypeName,
  342. status: this.screenForm.status,
  343. };
  344. getWalletList(params).then((res) => {
  345. this.dataList = res.data.records;
  346. this.listTotal = res.data.total;
  347. this.listLoading = false;
  348. });
  349. getProductList({
  350. productCategoryName: "",
  351. productCategoryNumber: "",
  352. }).then((res) => {
  353. this.productList = res.data;
  354. });
  355. },
  356. handleChange(e) {
  357. console.log(e, this.typeList);
  358. this.typeList.find((k) => {
  359. if (e == k.saleCode) {
  360. this.dialogForm.saleTypeName = k.saleName;
  361. this.dialogForm.mainId = k.mainId;
  362. this.dialogForm.mainName = k.mainName;
  363. }
  364. });
  365. },
  366. handleNumber(e){
  367. console.log(e)
  368. if (Number(e)<0) {
  369. this.dialogForm.rebateRate = 0.1
  370. }else if(Number(e)>1){
  371. this.dialogForm.rebateRate = 0.9
  372. }else{
  373. this.dialogForm.rebateRate = e
  374. }
  375. },
  376. handleSwitch(e, walletRebateId) {
  377. updateWallet({
  378. walletRebateId,
  379. status: e,
  380. }).then((res) => {
  381. this.$successMsg("状态已更改");
  382. // this.hanleReset();
  383. });
  384. },
  385. hanleEdit(item) {
  386. console.log(item);
  387. this.dialogForm = {
  388. adminCompanyId: item.adminCompanyId,
  389. mainId: item.mainId,
  390. mainName: item.mainName,
  391. name: item.name,
  392. rebateRate: item.rebateRate,
  393. rabateSort: item.rabateSort,
  394. saleTypeCode: item.saleTypeCode,
  395. saleTypeId: item.saleTypeId,
  396. saleTypeName: item.saleTypeName,
  397. status: item.status,
  398. walletRebateId: item.walletRebateId,
  399. };
  400. this.getDictList();
  401. this.dialogVisible = true;
  402. },
  403. getDictList() {
  404. getDictList({
  405. sysDictEnum: "PRODUCT_TYPE",
  406. }).then((res) => {
  407. console.log(res);
  408. this.dictListData = res.data;
  409. });
  410. const params = {
  411. pageNum: 1,
  412. pageSize: 10,
  413. saleCode: "",
  414. saleName: "",
  415. status: "",
  416. };
  417. getTypeList(params).then((res) => {
  418. this.typeList = res.data.records;
  419. });
  420. },
  421. hanleDateil(item) {
  422. this.type = 3;
  423. this.dialogVisible = true;
  424. this.dialogForm = {
  425. ...item,
  426. };
  427. },
  428. hanelclose() {
  429. this.type = "";
  430. this.hanleReset();
  431. this.$refs.dialogForm.resetFields();
  432. },
  433. handelInfo() {
  434. console.log(this.$refs.dialogForm);
  435. this.$refs.dialogForm.validate((valid) => {
  436. if (valid) {
  437. if (this.type) {
  438. this.hanleScreen(this.dialogForm.mainId);
  439. const params = {
  440. ...this.dialogForm,
  441. };
  442. addWallet(params).then((res) => {
  443. console.log(res);
  444. this.$successMsg("添加成功");
  445. this.hanleReset();
  446. });
  447. } else {
  448. const upParams = {
  449. ...this.dialogForm,
  450. };
  451. updateWallet(upParams).then((res) => {
  452. this.$successMsg("修改成功");
  453. this.hanleReset();
  454. });
  455. }
  456. } else {
  457. console.log("error submit!!");
  458. return false;
  459. }
  460. });
  461. },
  462. hanleReset() {
  463. this.dialogForm = {
  464. name: "",
  465. mainId: "",
  466. mainName: "",
  467. saleTypeCode: "",
  468. saleTypeName: "",
  469. rabateRate: "",
  470. status: true,
  471. };
  472. // this.$refs.dialogForm.resetFields()
  473. this.dialogVisible = false;
  474. this.getList();
  475. },
  476. hanleCancel() {
  477. this.hanleReset();
  478. this.dialogVisible = false;
  479. },
  480. hanleScreen(code) {
  481. this.dictListData.find((k) => {
  482. if (k.dictCode == code) {
  483. this.dialogForm.mainId = k.dictCode;
  484. this.dialogForm.mainName = k.dictValue;
  485. return;
  486. }
  487. });
  488. },
  489. },
  490. components: {
  491. Pagination,
  492. },
  493. };
  494. </script>
  495. <style scoped>
  496. .el-switch.is-disabled {
  497. opacity: inherit;
  498. }
  499. ::v-deep .el-select {
  500. width: 100%;
  501. }
  502. </style>