rebate_list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  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. disabled
  99. :active-value="true"
  100. :inactive-value="false"
  101. :active-text="scope.row.status ? '已启用' : '已禁用'"
  102. >
  103. </el-switch>
  104. </template>
  105. </el-table-column>
  106. <el-table-column
  107. v-else
  108. align="center"
  109. :label="col.lable"
  110. :prop="col.prop"
  111. :min-width="col.widht"
  112. show-overflow-tooltip
  113. >
  114. </el-table-column>
  115. </template>
  116. <el-table-column
  117. align="center"
  118. fixed="right"
  119. label="操作"
  120. min-width="160"
  121. >
  122. <template slot-scope="scope">
  123. <el-button type="text" size="small" @click="hanleDateil(scope.row)"
  124. >查看</el-button
  125. >
  126. <el-button type="text" size="small" @click="hanleEdit(scope.row)"
  127. >编辑</el-button
  128. >
  129. <!-- <el-button type="text" size="small">编辑</el-button> -->
  130. </template>
  131. </el-table-column>
  132. </el-table>
  133. <Pagination />
  134. </div>
  135. <div>
  136. <el-dialog :visible.sync="dialogVisible" width="50%" @close="hanelclose">
  137. <el-form
  138. :model="dialogForm"
  139. ref="dialogForm"
  140. label-width="120px"
  141. :inline="false"
  142. size="normal"
  143. >
  144. <el-form-item label="返利使用钱包" prop="name">
  145. <el-input
  146. v-model="dialogForm.name"
  147. :disabled="type == 3"
  148. ></el-input>
  149. </el-form-item>
  150. <el-form-item label="产品使用品类" prop="mainName">
  151. <el-select
  152. v-model="dialogForm.mainName"
  153. :disabled="type == 3"
  154. placeholder="请选择品类"
  155. size="small"
  156. >
  157. <el-option
  158. v-for="item in dictListData"
  159. :key="item.dictCode"
  160. :label="item.dictValue"
  161. :value="item.dictCode"
  162. >
  163. </el-option>
  164. </el-select>
  165. </el-form-item>
  166. <el-form-item label="销售类型编码" prop="saleTypeCode">
  167. <el-select
  168. v-model="dialogForm.saleTypeCode"
  169. :disabled="type == 3"
  170. placeholder="请选择类型编码"
  171. size="small"
  172. >
  173. <el-option
  174. v-for="item in typeList"
  175. :key="item.sysDictId"
  176. :label="item.dictValue"
  177. :value="item.saleCode"
  178. >
  179. </el-option>
  180. </el-select>
  181. </el-form-item>
  182. <el-form-item label="销售类型名称" prop="saleTypeName">
  183. <el-input
  184. v-model="dialogForm.saleTypeName"
  185. :disabled="type == 3"
  186. ></el-input>
  187. </el-form-item>
  188. <el-form-item label="返利折扣比例" prop="rabateRate">
  189. <el-input
  190. placeholder="例如:0.1=1折"
  191. :disabled="type == 3"
  192. v-model="dialogForm.rabateRate"
  193. ></el-input>
  194. </el-form-item>
  195. <el-form-item label="状态" prop="status">
  196. <el-switch
  197. v-model="dialogForm.status"
  198. :disabled="type == 3"
  199. :active-value="true"
  200. :inactive-value="false"
  201. :active-text="dialogForm.status ? '启用' : ''"
  202. >
  203. </el-switch>
  204. </el-form-item>
  205. </el-form>
  206. <template v-if="type !== 3">
  207. <span slot="footer" class="dialog-footer">
  208. <el-button @click="hanleCancel">取 消</el-button>
  209. <el-button type="primary" @click="handelInfo">确 定</el-button>
  210. </span>
  211. </template>
  212. </el-dialog>
  213. </div>
  214. </div>
  215. </template>
  216. <script>
  217. import Mixin from "@/mixin/index";
  218. import Pagination from "@/components/Pagination";
  219. import {
  220. addWallet,
  221. getDictList,
  222. getTypeList,
  223. updateWallet,
  224. getWalletList,
  225. getWalletDetail,
  226. } from "@/api/supply/sales";
  227. export default {
  228. mixins: [Mixin],
  229. data() {
  230. return {
  231. type: 0, // 0 1
  232. screenForm: {
  233. mainName: "",
  234. saleTypeCode: "",
  235. saleTypeName: "",
  236. status: true,
  237. },
  238. dialogForm: {
  239. name: "",
  240. mainName: "",
  241. mainId: "",
  242. saleTypeCode: "",
  243. saleTypeName: "",
  244. rabateRate: "",
  245. status: true,
  246. },
  247. dataList: [],
  248. columns: [
  249. {
  250. prop: "saleTypeCode",
  251. lable: "销售类型编码",
  252. widht: 160,
  253. },
  254. {
  255. prop: "saleTypeName",
  256. lable: "销售类型名称",
  257. widht: 160,
  258. },
  259. {
  260. prop: "name",
  261. lable: "返利使用钱包",
  262. widht: 160,
  263. },
  264. {
  265. prop: "rabateRate",
  266. lable: "返利折扣比例",
  267. widht: 160,
  268. },
  269. {
  270. prop: "status",
  271. lable: "状态",
  272. widht: 160,
  273. },
  274. {
  275. prop: "createBy",
  276. lable: "创建人",
  277. widht: 160,
  278. },
  279. {
  280. prop: "createTime",
  281. lable: "创建时间",
  282. widht: 160,
  283. },
  284. {
  285. prop: "updateBy",
  286. lable: "更新人",
  287. widht: 160,
  288. },
  289. {
  290. prop: "updateTime",
  291. lable: "更新时间",
  292. widht: 160,
  293. },
  294. ],
  295. options: [
  296. {
  297. value: true,
  298. label: "已启用",
  299. },
  300. {
  301. value: false,
  302. label: "已停用",
  303. },
  304. ],
  305. dictListData: [],
  306. typeList: [],
  307. };
  308. },
  309. methods: {
  310. getList() {
  311. this.listLoading = true;
  312. const params = {
  313. pageNum: this.currentPage,
  314. pageSize: this.pageSize,
  315. mainName: this.screenForm.mainName,
  316. saleTypeCode: this.screenForm.saleTypeCode,
  317. saleTypeName: this.screenForm.saleTypeName,
  318. status: this.screenForm.status,
  319. };
  320. getWalletList(params).then((res) => {
  321. this.dataList = res.data.records;
  322. this.listLoading = false;
  323. });
  324. },
  325. hanleEdit(item) {
  326. this.dialogForm = {
  327. id: item.id,
  328. name: item.name,
  329. mainName: item.mainName,
  330. saleTypeCode: item.saleTypeCode,
  331. saleTypeName: item.saleTypeName,
  332. rabateRate: item.rabateRate,
  333. status: item.status,
  334. };
  335. this.getDictList();
  336. this.dialogVisible = true;
  337. },
  338. getDictList() {
  339. getDictList({
  340. sysDictEnum: "PRODUCT_TYPE",
  341. }).then((res) => {
  342. console.log(res);
  343. this.dictListData = res.data;
  344. });
  345. const params = {
  346. pageNum: 1,
  347. pageSize: 10,
  348. saleCode: "",
  349. saleName: "",
  350. status: "",
  351. };
  352. getTypeList(params).then((res) => {
  353. this.typeList = res.data.records;
  354. });
  355. },
  356. hanleDateil(item) {
  357. this.type = 3;
  358. this.dialogVisible = true;
  359. this.dialogForm = {
  360. ...item,
  361. };
  362. },
  363. hanelclose() {
  364. this.type = "";
  365. this.hanleReset();
  366. },
  367. handelInfo() {
  368. if (this.type) {
  369. this.hanleScreen(this.dialogForm.mainId);
  370. const params = {
  371. ...this.dialogForm,
  372. };
  373. addWallet(params).then((res) => {
  374. console.log(res);
  375. this.$successMsg("添加成功");
  376. this.hanleReset();
  377. });
  378. } else {
  379. const upParams = {
  380. ...this.dialogForm,
  381. };
  382. updateType(upParams).then((res) => {
  383. this.$successMsg("修改成功");
  384. this.hanleReset();
  385. });
  386. }
  387. },
  388. hanleReset() {
  389. this.dialogForm = {
  390. name: "",
  391. mainId: "",
  392. mainName: "",
  393. saleTypeCode: "",
  394. saleTypeName: "",
  395. rabateRate: "",
  396. status: true,
  397. };
  398. // this.$refs.dialogForm.resetFields()
  399. this.dialogVisible = false;
  400. this.getList();
  401. },
  402. hanleCancel() {
  403. this.hanleReset();
  404. this.dialogVisible = false;
  405. },
  406. hanleScreen(code) {
  407. this.dictListData.find((k) => {
  408. if (k.dictCode == code) {
  409. this.dialogForm.mainId = k.dictCode;
  410. this.dialogForm.mainName = k.dictValue;
  411. return;
  412. }
  413. });
  414. },
  415. },
  416. components: {
  417. Pagination,
  418. },
  419. };
  420. </script>
  421. <style scoped></style>