rebate_list.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  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. icon="el-icon-plus"
  61. v-if="$checkBtnRole('add', $route.meta.roles)"
  62. @click="(dialogVisible = true), (type = 1), getDictList()"
  63. >新增</el-button
  64. >
  65. <!-- <el-button type="primary" size="small" @click="delfn"
  66. >批量删除</el-button
  67. > -->
  68. <el-popconfirm
  69. v-if="$checkBtnRole('del', $route.meta.roles)"
  70. class="delClass"
  71. @onConfirm="delfn"
  72. title="这是一段内容确定删除吗?"
  73. >
  74. <el-button
  75. :disabled="ids.length < 1"
  76. slot="reference"
  77. type="danger"
  78. icon="el-icon-minus"
  79. size="small"
  80. >批量删除</el-button
  81. >
  82. </el-popconfirm>
  83. <el-button
  84. icon="el-icon-search"
  85. type="primary"
  86. size="small"
  87. @click="submitScreenForm"
  88. >查询</el-button
  89. >
  90. <el-button type="primary" size="small" @click="resetScreenForm"
  91. >重置</el-button
  92. >
  93. </el-form-item>
  94. </el-col>
  95. </el-row>
  96. </el-form>
  97. </div>
  98. <div class="mymain-container">
  99. <el-table
  100. v-loading="listLoading"
  101. :data="dataList"
  102. element-loading-text="Loading"
  103. border
  104. fit
  105. highlight-current-row
  106. stripe
  107. @selection-change="selectionhangeFn"
  108. >
  109. <!-- <div v-for="(col, i) in columns" :key="i"> -->
  110. <el-table-column type="selection" width="55" align="center">
  111. </el-table-column>
  112. <template v-for="col in columns">
  113. <el-table-column
  114. align="center"
  115. :label="col.lable"
  116. :prop="col.prop"
  117. :min-width="col.widht"
  118. show-overflow-tooltip
  119. v-if="col.prop == 'status'"
  120. >
  121. <template slot-scope="scope">
  122. <el-switch
  123. v-model="scope.row.status"
  124. @change="handleSwitch($event, scope.row.walletRebateSaleTypeId)"
  125. :active-text="scope.row.status ? '已启用' : '已禁用'"
  126. >
  127. </el-switch>
  128. </template>
  129. </el-table-column>
  130. <el-table-column
  131. v-else
  132. align="center"
  133. :label="col.lable"
  134. :prop="col.prop"
  135. :min-width="col.widht"
  136. show-overflow-tooltip
  137. >
  138. </el-table-column>
  139. </template>
  140. <!-- </div> -->
  141. <el-table-column
  142. align="center"
  143. fixed="right"
  144. label="操作"
  145. min-width="160"
  146. >
  147. <template slot-scope="scope">
  148. <el-button type="text" size="small" @click="hanleDateil(scope.row)"
  149. >查看</el-button
  150. >
  151. <el-button
  152. type="text"
  153. size="small"
  154. @click="hanleEdit(scope.row)"
  155. v-if="$checkBtnRole('edit', $route.meta.roles)"
  156. >编辑</el-button
  157. >
  158. <!-- <el-button type="text" size="small">编辑</el-button> -->
  159. </template>
  160. </el-table-column>
  161. </el-table>
  162. <!-- 分页 -->
  163. <div class="fr">
  164. <el-pagination
  165. @size-change="handleSizeChange"
  166. @current-change="handleCurrentChange"
  167. :current-page="currentPage"
  168. :page-sizes="[10, 20, 30, 50]"
  169. :page-size="10"
  170. layout="total, sizes, prev, pager, next, jumper"
  171. :total="listTotal"
  172. >
  173. </el-pagination>
  174. </div>
  175. </div>
  176. <div>
  177. <el-dialog
  178. :visible.sync="dialogVisible"
  179. width="30%"
  180. @close="hanelclose"
  181. title="返利类型"
  182. >
  183. <el-form
  184. :model="dialogForm"
  185. ref="dialogForm"
  186. :rules="rules"
  187. label-width="120px"
  188. :inline="false"
  189. size="normal"
  190. >
  191. <el-form-item label="返利使用钱包" prop="walletRebateId">
  192. <!-- <el-input
  193. v-model="dialogForm.name"
  194. :readonly="type == 3"
  195. ></el-input> -->
  196. <el-select
  197. v-model="dialogForm.walletRebateId"
  198. :disabled="type == 3"
  199. placeholder="请选择钱包"
  200. >
  201. <el-option
  202. v-for="item in walletList"
  203. :key="item.walletRebateId"
  204. :label="item.name"
  205. :value="item.walletRebateId"
  206. >
  207. </el-option>
  208. </el-select>
  209. </el-form-item>
  210. <el-form-item label="销售类型名称" prop="saleTypeId">
  211. <el-select
  212. v-model="dialogForm.saleTypeId"
  213. :disabled="type == 3"
  214. filterable
  215. @change="handleChange"
  216. placeholder="请选择销售类型编码"
  217. >
  218. <el-option
  219. v-for="item in typeList"
  220. :key="item.id"
  221. :label="item.saleName"
  222. :value="item.id"
  223. >
  224. </el-option>
  225. </el-select>
  226. </el-form-item>
  227. <el-form-item label="返利折扣比例" prop="rebateRate">
  228. <el-input
  229. type="number"
  230. placeholder="例如0.1=1折"
  231. :disabled="type == 3"
  232. @change="handleNumber"
  233. v-model.number="dialogForm.rebateRate"
  234. ></el-input>
  235. </el-form-item>
  236. <!-- <el-form-item label="销售类型编码" prop="saleTypeCode">
  237. <el-input
  238. v-model="dialogForm.saleTypeCode"
  239. :readonly="true"
  240. ></el-input>
  241. </el-form-item> -->
  242. <!-- <el-form-item label="产品使用品类" prop="mainName">
  243. <el-input v-model="dialogForm.mainName" :readonly="true"></el-input>
  244. </el-form-item> -->
  245. <el-form-item label="状态" prop="status">
  246. <el-switch
  247. v-model="dialogForm.status"
  248. :disabled="type == 3"
  249. :active-value="true"
  250. :inactive-value="false"
  251. :active-text="dialogForm.status ? '启用' : ''"
  252. >
  253. </el-switch>
  254. </el-form-item>
  255. </el-form>
  256. <template v-if="type !== 3">
  257. <span slot="footer" class="dialog-footer">
  258. <el-button @click="hanleCancel">取 消</el-button>
  259. <el-button type="primary" @click="handelInfo">确 定</el-button>
  260. </span>
  261. </template>
  262. </el-dialog>
  263. </div>
  264. </div>
  265. </template>
  266. <script>
  267. import Mixin from "@/mixin/index";
  268. import Pagination from "@/components/Pagination";
  269. import {
  270. addWallet,
  271. getDictList,
  272. getTypeList,
  273. updateWallet,
  274. getWalletList,
  275. getWalletDetail,
  276. getProductList,
  277. getWalletRebateSaletypelist,
  278. getWalletRebateList,
  279. getWalletRebateSaletypeAdd,
  280. getWalletRebateSaletypeDelete,
  281. getWalletRebateSaletypeUpdate,
  282. } from "@/api/policy_list";
  283. export default {
  284. mixins: [Mixin],
  285. data() {
  286. return {
  287. ids: [],
  288. walletList: [],
  289. type: 0, // 0 1
  290. screenForm: {
  291. // mainName: "",
  292. saleTypeCode: "",
  293. saleTypeName: "",
  294. status: "",
  295. },
  296. dialogForm: {
  297. walletRebateId: "",
  298. rebateRate: "",
  299. saleTypeId: "",
  300. status: "",
  301. },
  302. dataList: [],
  303. columns: [
  304. {
  305. prop: "saleTypeCode",
  306. lable: "销售类型编码",
  307. widht: 160,
  308. },
  309. {
  310. prop: "saleTypeName",
  311. lable: "销售类型名称",
  312. widht: 160,
  313. },
  314. {
  315. prop: "name",
  316. lable: "返利类型",
  317. widht: 160,
  318. },
  319. {
  320. prop: "rebateRate",
  321. lable: "返利折扣比例",
  322. widht: 160,
  323. },
  324. {
  325. prop: "status",
  326. lable: "状态",
  327. widht: 160,
  328. },
  329. {
  330. prop: "createBy",
  331. lable: "创建人",
  332. widht: 160,
  333. },
  334. {
  335. prop: "createTime",
  336. lable: "创建时间",
  337. widht: 160,
  338. },
  339. {
  340. prop: "updateBy",
  341. lable: "更新人",
  342. widht: 160,
  343. },
  344. {
  345. prop: "updateTime",
  346. lable: "更新时间",
  347. widht: 160,
  348. },
  349. ],
  350. options: [
  351. {
  352. value: "",
  353. label: "全部",
  354. },
  355. {
  356. value: 1,
  357. label: "已启用",
  358. },
  359. {
  360. value: 0,
  361. label: "已停用",
  362. },
  363. ],
  364. dictListData: [],
  365. typeList: [],
  366. rules: {
  367. walletRebateId: [
  368. { required: true, message: "请输入名称", trigger: "blur" },
  369. ],
  370. saleTypeId: [
  371. { required: true, message: "请选择销售类型", trigger: "blur" },
  372. ],
  373. rebateRate: [
  374. { required: true, message: "请输入比例", trigger: "blur" },
  375. ],
  376. },
  377. };
  378. },
  379. methods: {
  380. //
  381. selectionhangeFn(value) {
  382. console.log(value);
  383. this.ids = value.map((v) => v.walletRebateSaleTypeId);
  384. },
  385. //删除
  386. async delfn() {
  387. // if (this.ids.length == 0) {
  388. // this.$message.error("请选择列表数据");
  389. // return;
  390. // }
  391. let res = this.ids.toString();
  392. await getWalletRebateSaletypeDelete({ walletRebateSaleTypeIds: res });
  393. this.getList();
  394. this.$message.success("删除成功");
  395. this.ids = [];
  396. },
  397. //获取钱包列表
  398. async getWalletList() {
  399. const res = await getWalletRebateList({
  400. pageNum: 1,
  401. pageSize: -1,
  402. });
  403. this.walletList = res.data.records;
  404. },
  405. getList() {
  406. this.listLoading = true;
  407. const params = {
  408. pageNum: this.currentPage,
  409. pageSize: this.pageSize,
  410. // mainName: this.screenForm.mainName,
  411. saleTypeCode: this.screenForm.saleTypeCode,
  412. saleTypeName: this.screenForm.saleTypeName,
  413. status: this.screenForm.status,
  414. };
  415. getWalletRebateSaletypelist(params).then((res) => {
  416. this.dataList = res.data.records;
  417. this.listTotal = res.data.total;
  418. this.listLoading = false;
  419. });
  420. // getProductList({
  421. // productCategoryName: "",
  422. // productCategoryNumber: "",
  423. // }).then((res) => {
  424. // this.productList = res.data;
  425. // });
  426. },
  427. handleChange(e) {
  428. console.log(e, this.typeList);
  429. this.typeList.find((k) => {
  430. if (e == k.saleCode) {
  431. this.dialogForm.saleTypeName = k.saleName;
  432. // this.dialogForm.mainId = k.mainId;
  433. // this.dialogForm.mainName = k.mainName;
  434. }
  435. });
  436. },
  437. handleNumber(e) {
  438. console.log(e);
  439. if (Number(e) < 0) {
  440. this.dialogForm.rebateRate = 0.1;
  441. } else if (Number(e) > 1) {
  442. this.dialogForm.rebateRate = 0.9;
  443. } else {
  444. this.dialogForm.rebateRate = e;
  445. }
  446. },
  447. handleSwitch(e, walletRebateSaleTypeId) {
  448. getWalletRebateSaletypeUpdate({
  449. walletRebateSaleTypeId,
  450. status: e,
  451. }).then((res) => {
  452. this.$successMsg("状态已更改");
  453. // this.hanleReset();
  454. });
  455. },
  456. hanleEdit(item) {
  457. console.log(item);
  458. this.dialogForm = {
  459. // adminCompanyId: item.adminCompanyId,
  460. name: item.name,
  461. rebateRate: item.rebateRate,
  462. // rabateSort: item.rabateSort,
  463. // saleTypeCode: item.saleTypeCode,
  464. saleTypeId: item.saleTypeId,
  465. // saleTypeName: item.saleTypeName,
  466. status: item.status,
  467. walletRebateId: item.walletRebateId,
  468. walletRebateSaleTypeId: item.walletRebateSaleTypeId,
  469. };
  470. this.getDictList();
  471. this.dialogVisible = true;
  472. },
  473. getDictList() {
  474. getDictList({
  475. sysDictEnum: "PRODUCT_TYPE",
  476. }).then((res) => {
  477. console.log(res);
  478. this.dictListData = res.data;
  479. });
  480. const params = {
  481. pageNum: 1,
  482. pageSize: 10,
  483. saleCode: "",
  484. saleName: "",
  485. status: "",
  486. };
  487. getTypeList(params).then((res) => {
  488. this.typeList = res.data.records;
  489. });
  490. },
  491. hanleDateil(item) {
  492. this.type = 3;
  493. this.dialogVisible = true;
  494. this.dialogForm = {
  495. ...item,
  496. saleTypeId: item.saleTypeName,
  497. };
  498. },
  499. hanelclose() {
  500. this.type = "";
  501. this.hanleReset();
  502. this.$refs.dialogForm.resetFields();
  503. },
  504. handelInfo() {
  505. console.log(this.$refs.dialogForm);
  506. this.$refs.dialogForm.validate((valid) => {
  507. if (valid) {
  508. if (this.type) {
  509. // this.hanleScreen(this.dialogForm.mainId);
  510. const params = {
  511. ...this.dialogForm,
  512. };
  513. getWalletRebateSaletypeAdd(params).then((res) => {
  514. console.log(res);
  515. this.$successMsg("添加成功");
  516. this.hanleReset();
  517. });
  518. } else {
  519. const upParams = {
  520. ...this.dialogForm,
  521. };
  522. getWalletRebateSaletypeUpdate(upParams).then((res) => {
  523. this.$successMsg("修改成功");
  524. this.hanleReset();
  525. });
  526. }
  527. } else {
  528. console.log("error submit!!");
  529. return false;
  530. }
  531. });
  532. },
  533. hanleReset() {
  534. this.dialogForm = {
  535. name: "",
  536. // mainId: "",
  537. // mainName: "",
  538. // saleTypeCode: "",
  539. // saleTypeName: "",
  540. // rabateRate: "",
  541. status: true,
  542. };
  543. // this.$refs.dialogForm.resetFields()
  544. this.dialogVisible = false;
  545. this.getList();
  546. },
  547. hanleCancel() {
  548. this.hanleReset();
  549. this.dialogVisible = false;
  550. },
  551. hanleScreen(code) {
  552. // this.dictListData.find((k) => {
  553. // if (k.dictCode == code) {
  554. // this.dialogForm.mainId = k.dictCode;
  555. // this.dialogForm.mainName = k.dictValue;
  556. // return;
  557. // }
  558. // });
  559. },
  560. },
  561. created() {
  562. this.getWalletList();
  563. },
  564. components: {
  565. Pagination,
  566. },
  567. };
  568. </script>
  569. <style scoped>
  570. .el-switch.is-disabled {
  571. opacity: inherit;
  572. }
  573. ::v-deep .el-select {
  574. width: 100%;
  575. }
  576. .delClass {
  577. margin: 0 10px;
  578. }
  579. </style>