rebate_list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  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. v-if="$checkBtnRole('add', $route.meta.roles)"
  61. @click="(dialogVisible = true), (type = 1), getDictList()"
  62. >新增</el-button
  63. >
  64. <el-button type="primary" size="small" @click="submitScreenForm"
  65. >查询</el-button
  66. >
  67. <el-button type="primary" size="small" @click="resetScreenForm"
  68. >重置</el-button
  69. >
  70. </el-form-item>
  71. </el-col>
  72. </el-row>
  73. </el-form>
  74. </div>
  75. <div class="mymain-container">
  76. <el-table
  77. v-loading="listLoading"
  78. :data="dataList"
  79. element-loading-text="Loading"
  80. border
  81. fit
  82. highlight-current-row
  83. stripe
  84. >
  85. <el-table-column type="selection" width="55" align="center">
  86. </el-table-column>
  87. <template v-for="col in columns">
  88. <el-table-column
  89. align="center"
  90. :label="col.lable"
  91. :prop="col.prop"
  92. :min-width="col.widht"
  93. show-overflow-tooltip
  94. v-if="col.prop == 'status'"
  95. >
  96. <template slot-scope="scope">
  97. <el-switch
  98. v-model="scope.row.status"
  99. @change="handleSwitch($event, scope.row.walletRebateId)"
  100. :active-text="scope.row.status ? '已启用' : '已禁用'"
  101. >
  102. </el-switch>
  103. </template>
  104. </el-table-column>
  105. <el-table-column
  106. v-else
  107. align="center"
  108. :label="col.lable"
  109. :prop="col.prop"
  110. :min-width="col.widht"
  111. show-overflow-tooltip
  112. >
  113. </el-table-column>
  114. </template>
  115. <el-table-column
  116. align="center"
  117. fixed="right"
  118. label="操作"
  119. min-width="160"
  120. >
  121. <template slot-scope="scope">
  122. <el-button type="text" size="small" @click="hanleDateil(scope.row)"
  123. >查看</el-button
  124. >
  125. <el-button type="text" size="small" @click="hanleEdit(scope.row)" v-if="$checkBtnRole('edit', $route.meta.roles)"
  126. >编辑</el-button
  127. >
  128. <!-- <el-button type="text" size="small">编辑</el-button> -->
  129. </template>
  130. </el-table-column>
  131. </el-table>
  132. <!-- 分页 -->
  133. <div class="fr">
  134. <el-pagination
  135. @size-change="handleSizeChange"
  136. @current-change="handleCurrentChange"
  137. :current-page="currentPage"
  138. :page-sizes="[10, 20, 30, 50]"
  139. :page-size="10"
  140. layout="total, sizes, prev, pager, next, jumper"
  141. :total="listTotal"
  142. >
  143. </el-pagination>
  144. </div>
  145. </div>
  146. <div>
  147. <el-dialog
  148. :visible.sync="dialogVisible"
  149. width="50%"
  150. @close="hanelclose"
  151. title="返利类型"
  152. >
  153. <el-form
  154. :model="dialogForm"
  155. ref="dialogForm"
  156. :rules="rules"
  157. label-width="120px"
  158. :inline="false"
  159. size="normal"
  160. >
  161. <el-form-item label="返利使用钱包" prop="name">
  162. <el-input
  163. v-model="dialogForm.name"
  164. :readonly="type == 3"
  165. ></el-input>
  166. </el-form-item>
  167. <el-form-item label="销售类型名称" prop="saleTypeName">
  168. <el-select
  169. v-model="dialogForm.saleTypeCode"
  170. :disabled="type == 3"
  171. @change="handleChange"
  172. placeholder="请选择销售类型编码"
  173. >
  174. <el-option
  175. v-for="item in typeList"
  176. :key="item.sysDictId"
  177. :label="item.saleName"
  178. :value="item.saleCode"
  179. >
  180. </el-option>
  181. </el-select>
  182. </el-form-item>
  183. <el-form-item label="销售类型编码" prop="saleTypeCode">
  184. <el-input
  185. v-model="dialogForm.saleTypeCode"
  186. :readonly="true"
  187. ></el-input>
  188. </el-form-item>
  189. <el-form-item label="产品使用品类" prop="mainName">
  190. <el-input v-model="dialogForm.mainName" :readonly="true"></el-input>
  191. </el-form-item>
  192. <el-form-item label="返利折扣比例" prop="rebateRate">
  193. <el-input
  194. type="number"
  195. placeholder="例如0.1=1折"
  196. :readonly="type == 3"
  197. @change="handleNumber"
  198. v-model.number="dialogForm.rebateRate"
  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. rebateRate: "",
  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: "mainName",
  268. lable: "产品大类",
  269. widht: 160,
  270. },
  271. {
  272. prop: "name",
  273. lable: "返利类型",
  274. widht: 160,
  275. },
  276. {
  277. prop: "rebateRate",
  278. lable: "返利折扣比例",
  279. widht: 160,
  280. },
  281. {
  282. prop: "status",
  283. lable: "状态",
  284. widht: 160,
  285. },
  286. {
  287. prop: "createBy",
  288. lable: "创建人",
  289. widht: 160,
  290. },
  291. {
  292. prop: "createTime",
  293. lable: "创建时间",
  294. widht: 160,
  295. },
  296. {
  297. prop: "updateBy",
  298. lable: "更新人",
  299. widht: 160,
  300. },
  301. {
  302. prop: "updateTime",
  303. lable: "更新时间",
  304. widht: 160,
  305. },
  306. ],
  307. options: [
  308. {
  309. value: "",
  310. label: "全部",
  311. },
  312. {
  313. value: 1,
  314. label: "已启用",
  315. },
  316. {
  317. value: 0,
  318. label: "已停用",
  319. },
  320. ],
  321. dictListData: [],
  322. typeList: [],
  323. rules: {
  324. name: [{ required: true, message: "请输入名称", trigger: "blur" }],
  325. saleTypeCode: [
  326. { required: true, message: "请选择编码", trigger: "blur" },
  327. ],
  328. rebateRate: [
  329. { required: true, message: "请输入比例", trigger: "blur" },
  330. ],
  331. },
  332. };
  333. },
  334. methods: {
  335. getList() {
  336. this.listLoading = true;
  337. const params = {
  338. pageNum: this.currentPage,
  339. pageSize: this.pageSize,
  340. mainName: this.screenForm.mainName,
  341. saleTypeCode: this.screenForm.saleTypeCode,
  342. saleTypeName: this.screenForm.saleTypeName,
  343. status: this.screenForm.status,
  344. };
  345. getWalletList(params).then((res) => {
  346. this.dataList = res.data.records;
  347. this.listTotal = res.data.total;
  348. this.listLoading = false;
  349. });
  350. getProductList({
  351. productCategoryName: "",
  352. productCategoryNumber: "",
  353. }).then((res) => {
  354. this.productList = res.data;
  355. });
  356. },
  357. handleChange(e) {
  358. console.log(e, this.typeList);
  359. this.typeList.find((k) => {
  360. if (e == k.saleCode) {
  361. this.dialogForm.saleTypeName = k.saleName;
  362. this.dialogForm.mainId = k.mainId;
  363. this.dialogForm.mainName = k.mainName;
  364. }
  365. });
  366. },
  367. handleNumber(e){
  368. console.log(e)
  369. if (Number(e)<0) {
  370. this.dialogForm.rebateRate = 0.1
  371. }else if(Number(e)>1){
  372. this.dialogForm.rebateRate = 0.9
  373. }else{
  374. this.dialogForm.rebateRate = e
  375. }
  376. },
  377. handleSwitch(e, walletRebateId) {
  378. updateWallet({
  379. walletRebateId,
  380. status: e,
  381. }).then((res) => {
  382. this.$successMsg("状态已更改");
  383. // this.hanleReset();
  384. });
  385. },
  386. hanleEdit(item) {
  387. console.log(item);
  388. this.dialogForm = {
  389. adminCompanyId: item.adminCompanyId,
  390. mainId: item.mainId,
  391. mainName: item.mainName,
  392. name: item.name,
  393. rebateRate: item.rebateRate,
  394. rabateSort: item.rabateSort,
  395. saleTypeCode: item.saleTypeCode,
  396. saleTypeId: item.saleTypeId,
  397. saleTypeName: item.saleTypeName,
  398. status: item.status,
  399. walletRebateId: item.walletRebateId,
  400. };
  401. this.getDictList();
  402. this.dialogVisible = true;
  403. },
  404. getDictList() {
  405. getDictList({
  406. sysDictEnum: "PRODUCT_TYPE",
  407. }).then((res) => {
  408. console.log(res);
  409. this.dictListData = res.data;
  410. });
  411. const params = {
  412. pageNum: 1,
  413. pageSize: 10,
  414. saleCode: "",
  415. saleName: "",
  416. status: "",
  417. };
  418. getTypeList(params).then((res) => {
  419. this.typeList = res.data.records;
  420. });
  421. },
  422. hanleDateil(item) {
  423. this.type = 3;
  424. this.dialogVisible = true;
  425. this.dialogForm = {
  426. ...item,
  427. };
  428. },
  429. hanelclose() {
  430. this.type = "";
  431. this.hanleReset();
  432. this.$refs.dialogForm.resetFields();
  433. },
  434. handelInfo() {
  435. console.log(this.$refs.dialogForm);
  436. this.$refs.dialogForm.validate((valid) => {
  437. if (valid) {
  438. if (this.type) {
  439. this.hanleScreen(this.dialogForm.mainId);
  440. const params = {
  441. ...this.dialogForm,
  442. };
  443. addWallet(params).then((res) => {
  444. console.log(res);
  445. this.$successMsg("添加成功");
  446. this.hanleReset();
  447. });
  448. } else {
  449. const upParams = {
  450. ...this.dialogForm,
  451. };
  452. updateWallet(upParams).then((res) => {
  453. this.$successMsg("修改成功");
  454. this.hanleReset();
  455. });
  456. }
  457. } else {
  458. console.log("error submit!!");
  459. return false;
  460. }
  461. });
  462. },
  463. hanleReset() {
  464. this.dialogForm = {
  465. name: "",
  466. mainId: "",
  467. mainName: "",
  468. saleTypeCode: "",
  469. saleTypeName: "",
  470. rabateRate: "",
  471. status: true,
  472. };
  473. // this.$refs.dialogForm.resetFields()
  474. this.dialogVisible = false;
  475. this.getList();
  476. },
  477. hanleCancel() {
  478. this.hanleReset();
  479. this.dialogVisible = false;
  480. },
  481. hanleScreen(code) {
  482. this.dictListData.find((k) => {
  483. if (k.dictCode == code) {
  484. this.dialogForm.mainId = k.dictCode;
  485. this.dialogForm.mainName = k.dictValue;
  486. return;
  487. }
  488. });
  489. },
  490. },
  491. components: {
  492. Pagination,
  493. },
  494. };
  495. </script>
  496. <style scoped>
  497. .el-switch.is-disabled {
  498. opacity: inherit;
  499. }
  500. ::v-deep .el-select {
  501. width: 100%;
  502. }
  503. </style>