dealer_stock.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. <template>
  2. <div class="app-container">
  3. <!-- 筛选条件 -->
  4. <div>
  5. <el-form
  6. ref="searchForm"
  7. :model="searchForm"
  8. label-width="100px"
  9. size="small"
  10. label-position="left"
  11. >
  12. <el-row :gutter="20">
  13. <el-col :xs="24" :sm="12" :lg="6">
  14. <el-form-item label="经销商名称" prop="customerName">
  15. <el-input
  16. v-model="searchForm.customerName"
  17. placeholder="请输入经销商名称"
  18. ></el-input>
  19. </el-form-item>
  20. </el-col>
  21. <el-col :xs="24" :sm="12" :lg="18">
  22. <el-form-item label="" class="fr">
  23. <el-button size="small" @click="clearFn">清空</el-button>
  24. <el-button size="small" type="primary" @click="searchFn"
  25. >搜索</el-button
  26. >
  27. </el-form-item>
  28. </el-col>
  29. </el-row>
  30. </el-form>
  31. </div>
  32. <div class="btn-group clearfix">
  33. <div class="fl">
  34. <el-button
  35. v-if="$checkBtnRole('add', $route.meta.roles)"
  36. type="primary"
  37. size="small"
  38. @click="addFn"
  39. class="add-right"
  40. icon="el-icon-plus"
  41. >新增</el-button
  42. >
  43. <el-popconfirm
  44. v-if="$checkBtnRole('del', $route.meta.roles)"
  45. @onConfirm="deleFn"
  46. title="这是一段内容确定删除吗?"
  47. >
  48. <el-button
  49. :disabled="ids.length < 1"
  50. type="danger"
  51. size="small"
  52. class="textColor"
  53. icon="el-icon-minus"
  54. slot="reference"
  55. >批量删除</el-button
  56. >
  57. </el-popconfirm>
  58. </div>
  59. </div>
  60. <div class="mymain-container">
  61. <!-- 列表 -->
  62. <div class="table">
  63. <el-table
  64. v-loading="listLoading"
  65. :data="dataList"
  66. @select="hanleSelect"
  67. @select-all="hanleSelect"
  68. element-loading-text="Loading"
  69. border
  70. fit
  71. highlight-current-row
  72. stripe
  73. >
  74. <el-table-column
  75. type="selection"
  76. align="center"
  77. min-width="100"
  78. ></el-table-column>
  79. <el-table-column
  80. align="center"
  81. label="经销商编码"
  82. prop="customerNumber"
  83. min-width="160"
  84. show-overflow-tooltip
  85. ></el-table-column>
  86. <el-table-column
  87. align="center"
  88. label="经销商名称"
  89. prop="customerName"
  90. min-width="160"
  91. show-overflow-tooltip
  92. ></el-table-column>
  93. <el-table-column
  94. align="center"
  95. label="钱包名称"
  96. prop="customerWalletName"
  97. min-width="160"
  98. show-overflow-tooltip
  99. ></el-table-column>
  100. <el-table-column
  101. align="center"
  102. label="业务员"
  103. prop="serviceName"
  104. min-width="160"
  105. show-overflow-tooltip
  106. ></el-table-column>
  107. <el-table-column
  108. align="center"
  109. label="创建人"
  110. prop="createBy"
  111. min-width="160"
  112. show-overflow-tooltip
  113. ></el-table-column>
  114. <el-table-column
  115. align="center"
  116. label="创建时间"
  117. prop="createTime"
  118. min-width="160"
  119. show-overflow-tooltip
  120. ></el-table-column>
  121. <el-table-column
  122. align="center"
  123. label="更新人"
  124. prop="updateBy"
  125. min-width="160"
  126. show-overflow-tooltip
  127. ></el-table-column>
  128. <el-table-column
  129. align="center"
  130. label="更新时间"
  131. prop="updateTime"
  132. min-width="160"
  133. show-overflow-tooltip
  134. ></el-table-column>
  135. <el-table-column
  136. align="center"
  137. label="操作"
  138. prop="caozuo"
  139. min-width="160"
  140. show-overflow-tooltip
  141. fixed="right"
  142. >
  143. <template slot-scope="scope">
  144. <el-button
  145. type="text"
  146. class="textColor"
  147. v-if="$checkBtnRole('edit', $route.meta.roles)"
  148. @click="editFn(scope.row.id)"
  149. >编辑</el-button
  150. >
  151. <el-popconfirm
  152. @onConfirm="deleFn(scope.row.id)"
  153. v-if="$checkBtnRole('del', $route.meta.roles)"
  154. title="这是一段内容确定删除吗?"
  155. >
  156. <el-button type="text" class="textColor" slot="reference"
  157. >删除</el-button
  158. ></el-popconfirm
  159. >
  160. </template>
  161. </el-table-column>
  162. </el-table>
  163. </div>
  164. <!-- 分页 -->
  165. <div class="fr">
  166. <el-pagination
  167. @size-change="handleSizeChange"
  168. @current-change="handleCurrentChange"
  169. :current-page="currentPage"
  170. :page-sizes="[10, 20, 30, 50]"
  171. :page-size="10"
  172. layout="total, sizes, prev, pager, next, jumper"
  173. :total="listTotal"
  174. >
  175. </el-pagination>
  176. </div>
  177. </div>
  178. <!-- 弹窗 -->
  179. <el-dialog
  180. :title="title"
  181. :visible.sync="dialogForm"
  182. width="30%"
  183. :show-close="false"
  184. :close-on-click-modal="false"
  185. >
  186. <el-form
  187. ref="addForm"
  188. :model="addForm"
  189. :rules="rules"
  190. label-width="100px"
  191. label-position="right"
  192. >
  193. <el-form-item label="经销商名称" prop="customerId">
  194. <el-select
  195. filterable
  196. class="selectStyle"
  197. v-model="addForm.customerId"
  198. placeholder="请选择"
  199. @change="changeFn"
  200. >
  201. <el-option
  202. v-for="item in dealerList"
  203. :key="item.id"
  204. :label="item.name"
  205. :value="item.id"
  206. >
  207. </el-option>
  208. </el-select>
  209. </el-form-item>
  210. <el-form-item label="经销商编码" prop="">
  211. <el-input disabled v-model="addForm.customerNumber"></el-input>
  212. <!-- <template slot-scope="scope">
  213. {{ scope.row }}
  214. </template> -->
  215. </el-form-item>
  216. <el-form-item label="钱包" prop="customerWalletId">
  217. <el-select
  218. class="selectStyle"
  219. v-model="addForm.customerWalletId"
  220. placeholder="请选择"
  221. filterable
  222. >
  223. <el-option
  224. v-for="item in walletList"
  225. :key="item.customerWalletId"
  226. :label="item.customerWalletName"
  227. :value="item.customerWalletId"
  228. >
  229. </el-option>
  230. </el-select>
  231. </el-form-item>
  232. <el-form-item label="一级区域" prop="oneParentId">
  233. <el-select
  234. class="selectStyle"
  235. v-model="addForm.oneParentId"
  236. placeholder="请选择"
  237. filterable
  238. @change="changeOneFn"
  239. >
  240. <el-option
  241. v-for="item in oneList"
  242. :key="item.adminWebsitId"
  243. :label="item.name"
  244. :value="item.adminWebsitId"
  245. >
  246. </el-option>
  247. </el-select>
  248. </el-form-item>
  249. <el-form-item label="二级区域" prop="">
  250. <el-select
  251. filterable
  252. class="selectStyle"
  253. v-model="addForm.twoParentId"
  254. placeholder="请选择"
  255. @change="changeTwoFn"
  256. >
  257. <el-option
  258. v-for="item in twoList"
  259. :key="item.adminWebsitId"
  260. :label="item.name"
  261. :value="item.adminWebsitId"
  262. >
  263. </el-option>
  264. </el-select>
  265. </el-form-item>
  266. <el-form-item label="三级区域" prop=""
  267. ><el-select
  268. class="selectStyle"
  269. v-model="addForm.threeParentId"
  270. placeholder="请选择"
  271. filterable
  272. @change="changeThreeFn"
  273. >
  274. <el-option
  275. v-for="item in threeList"
  276. :key="item.adminWebsitId"
  277. :label="item.name"
  278. :value="item.adminWebsitId"
  279. >
  280. </el-option>
  281. </el-select>
  282. </el-form-item>
  283. <el-form-item label="对应业务员" prop="serviceId">
  284. <el-select
  285. class="selectStyle"
  286. v-model="addForm.serviceId"
  287. placeholder="请选择"
  288. filterable
  289. >
  290. <el-option
  291. v-for="(item, i) in userList"
  292. :key="i"
  293. :label="item.nickName"
  294. :value="item.adminUserId"
  295. >
  296. </el-option>
  297. </el-select>
  298. </el-form-item>
  299. </el-form>
  300. <div slot="footer" class="dialog-footer">
  301. <el-button @click="cancelFn">取 消</el-button>
  302. <el-button type="primary" @click="addDataListFn">确 定</el-button>
  303. </div>
  304. </el-dialog>
  305. </div>
  306. </template>
  307. <script>
  308. import {
  309. getDealerStockList,
  310. getDealerStockAdd,
  311. deleDealerStockList,
  312. getDictionaries,
  313. getProductCategoryList,
  314. getAdminWebsitByparent,
  315. getAdminUserList,
  316. getCustomerPtDetail,
  317. getCustomerPtUpdate,
  318. getWalletCustomerList,
  319. } from "@/api/basic_data/dealer";
  320. import { getDealerList } from "@/api/basic_data/dealer";
  321. export default {
  322. data() {
  323. return {
  324. isDisabled: true,
  325. title: "",
  326. dialogForm: false,
  327. addForm: {
  328. customerId: "",
  329. customerName: "",
  330. customerNumber: "",
  331. oneParentId: "",
  332. twoParentId: "",
  333. threeParentId: "",
  334. serviceId: "",
  335. customerWalletId: "",
  336. },
  337. mainId: null,
  338. rules: {
  339. customerId: [
  340. { required: true, message: "请选择经销商名称", trigger: "blur" },
  341. ],
  342. customerWalletId: [
  343. { required: true, message: "请选择经销商钱包", trigger: "blur" },
  344. ],
  345. oneParentId: [
  346. { required: true, message: "请选择一级区域", trigger: "blur" },
  347. ],
  348. // twoParentId: [
  349. // { required: true, message: "请选择二级区域", trigger: "blur" },
  350. // ],
  351. // threeParentId: [
  352. // { required: true, message: "请选择三级区域", trigger: "blur" },
  353. // ],
  354. serviceId: [
  355. { required: true, message: "请选择业务员", trigger: "blur" },
  356. ],
  357. },
  358. currentPage: 1, // 当前页码
  359. pageSize: 10, // 每页数量
  360. listTotal: 0, // 列表总数
  361. searchForm: {
  362. customerName: "",
  363. },
  364. dataList: [], // 列表数据
  365. listLoading: false, // 列表加载loading
  366. dealerList: [],
  367. // selectList: [],
  368. walletList: [], //产品大类列表
  369. oneList: [], //一级区域数据
  370. twoList: [], //二级区域数据
  371. threeList: [], //三级区域数据
  372. userList: [], //业务员
  373. ids: [],
  374. rowID: null, //编辑ID
  375. };
  376. },
  377. async created() {
  378. this.getAdminWebsit(1);
  379. this.getList({ pageNum: 1, pageSize: 10 });
  380. this.getDealerDataList({ pageNum: 1, pageSize: -1 });
  381. this.getUserList(1);
  382. // this.getSelectList({ sysDictEnum: "PRODUCT_TYPE" });
  383. },
  384. computed: {},
  385. watch: {
  386. "addForm.customerId": async function (newValue) {
  387. if (newValue) {
  388. // this.addForm.customerWalletId = "";
  389. const res = this.dealerList.filter((i) => i.id == newValue);
  390. this.addForm.customerName = res[0].name;
  391. this.addForm.customerNumber = res[0].number;
  392. let res2 = await getWalletCustomerList({
  393. customerId: newValue,
  394. type: "COMMONLY",
  395. });
  396. this.walletList = res2.data;
  397. }
  398. },
  399. "addForm.oneParentId": async function (newValue) {
  400. if (newValue) {
  401. let res = await getAdminWebsitByparent({
  402. parentId: newValue,
  403. // mainId: this.mainId,
  404. });
  405. this.twoList = res.data;
  406. }
  407. },
  408. "addForm.twoParentId": async function (newValue) {
  409. if (newValue) {
  410. let res = await getAdminWebsitByparent({
  411. parentId: newValue,
  412. // mainId: this.mainId,
  413. });
  414. this.getUserList(newValue);
  415. this.threeList = res.data;
  416. }
  417. },
  418. "addForm.threeParentId": async function (newValue) {
  419. if (newValue) {
  420. this.getUserList(newValue);
  421. }
  422. },
  423. },
  424. methods: {
  425. // //改变产品大类
  426. // changeSelectFn(value) {
  427. // // const res = this.categoryList.filter((v) => v.productCategoryId == value);
  428. // // console.log(res);
  429. // // this.mainId = res[0].productCategoryNumber;
  430. // },
  431. //编辑
  432. async changeFn(v) {
  433. this.addForm.customerWalletId = "";
  434. },
  435. async changeOneFn(v) {
  436. this.addForm.twoParentId = "";
  437. this.addForm.threeParentId = "";
  438. this.addForm.serviceId = "";
  439. },
  440. async changeTwoFn(v) {
  441. this.addForm.threeParentId = "";
  442. this.addForm.serviceId = "";
  443. },
  444. async changeThreeFn(v) {
  445. this.addForm.serviceId = "";
  446. },
  447. async editFn(id) {
  448. this.title = "经销商业务关系管理 ";
  449. this.rowID = id;
  450. let res = await getCustomerPtDetail({ id });
  451. console.log(res);
  452. this.addForm.customerId = res.data.customerId;
  453. this.addForm.customerWalletId = res.data.customerWalletId;
  454. this.addForm.oneParentId = res.data.adminWebsitId1;
  455. this.addForm.twoParentId = res.data.adminWebsitId2;
  456. this.addForm.threeParentId = res.data.adminWebsitId3;
  457. this.addForm.serviceId = res.data.serviceId;
  458. this.dialogForm = true;
  459. },
  460. //获取业务员数据
  461. async getUserList(v) {
  462. let res = await getAdminUserList({
  463. pageNum: 1,
  464. pageSize: -1,
  465. isCustomer: 0,
  466. adminWebsitId: v,
  467. });
  468. this.userList = res.data.records;
  469. },
  470. //根据父级查询部门
  471. async getAdminWebsit(data) {
  472. let res = await getAdminWebsitByparent({
  473. parentId: data,
  474. // mainId: this.mainId,
  475. });
  476. this.oneList = res.data;
  477. },
  478. // //获取产品品类数据
  479. // async getCategoryList() {
  480. // let res = await getProductCategoryList();
  481. // console.log(res);
  482. // this.categoryList = res.data;
  483. // },
  484. // 筛选部分数据或者单个
  485. hanleSelect(selection) {
  486. // this.ids = selection.map((k) => {
  487. // return k.id;
  488. // });
  489. // console.log(selection);
  490. this.ids = selection.map((v) => v.id);
  491. },
  492. // //存货分类
  493. // async getSelectList(data) {
  494. // const res = await getDictionaries(data);
  495. // console.log(res);
  496. // this.selectList = res.data;
  497. // },
  498. //删除
  499. async deleFn(id) {
  500. if (id) {
  501. let arr = [];
  502. arr.push(id);
  503. let res2 = arr.toString();
  504. await deleDealerStockList({ ids: res2 });
  505. } else {
  506. let res = this.ids.toString();
  507. await deleDealerStockList({ ids: res });
  508. }
  509. this.getList({ pageNum: 1, pageSize: 10 });
  510. this.$message.success("删除成功");
  511. this.ids = [];
  512. },
  513. addFn() {
  514. this.title = "经销商业务关系管理";
  515. this.dialogForm = true;
  516. },
  517. async addDataListFn() {
  518. await this.$refs.addForm.validate();
  519. let data2 = this.walletList.filter((v) => {
  520. return v.customerWalletId == this.addForm.customerWalletId;
  521. });
  522. let data3 = this.userList.filter((v) => {
  523. return v.adminUserId == this.addForm.serviceId;
  524. });
  525. console.log(data3);
  526. console.log(data2, 22222);
  527. let value = {
  528. customerId: this.addForm.customerId,
  529. customerName: this.addForm.customerName,
  530. customerNumber: this.addForm.customerNumber,
  531. customerWalletId: this.addForm.customerWalletId,
  532. customerWalletName: data2[0].customerWalletName,
  533. serviceId: this.addForm.serviceId,
  534. serviceName: data3[0].nickName,
  535. };
  536. if (this.title == "经销商业务关系管理 ") {
  537. await getCustomerPtUpdate({ ...value, id: this.rowID });
  538. this.$message.success("编辑成功");
  539. } else {
  540. await getDealerStockAdd(value);
  541. this.$message.success("添加成功");
  542. }
  543. this.addForm.customerId = "";
  544. this.addForm.customerNumber = "";
  545. this.addForm.customerName = "";
  546. this.addForm.customerWalletId = "";
  547. this.addForm.oneParentId = "";
  548. this.addForm.twoParentId = "";
  549. this.addForm.threeParentId = "";
  550. this.addForm.serviceId = "";
  551. this.userList = [];
  552. this.twoList = [];
  553. this.threeList = [];
  554. this.getList({ pageNum: 1, pageSize: 10 });
  555. this.dialogForm = false;
  556. },
  557. //取消
  558. async cancelFn() {
  559. await this.$refs.addForm.clearValidate();
  560. this.addForm.customerId = "";
  561. this.addForm.customerNumber = "";
  562. this.addForm.customerWalletId = "";
  563. this.addForm.oneParentId = "";
  564. this.addForm.twoParentId = "";
  565. this.addForm.threeParentId = "";
  566. this.addForm.serviceId = "";
  567. this.userList = [];
  568. this.twoList = [];
  569. this.threeList = [];
  570. this.dialogForm = false;
  571. },
  572. //获取经销商数据
  573. async getDealerDataList(data) {
  574. const res = await getDealerList(data);
  575. this.dealerList = res.data.records;
  576. },
  577. // 更改每页数量
  578. handleSizeChange(val) {
  579. this.pageSize = val;
  580. this.currentPage = 1;
  581. this.getList({
  582. pageNum: 1,
  583. pageSize: this.pageSize,
  584. customerName: this.searchForm.customerName,
  585. });
  586. },
  587. // 更改当前页
  588. handleCurrentChange(val) {
  589. this.currentPage = val;
  590. this.getList({
  591. pageNum: val,
  592. pageSize: 10,
  593. customerName: this.searchForm.customerName,
  594. });
  595. },
  596. //搜索功能
  597. async searchFn() {
  598. console.log(this.searchForm);
  599. await this.getList({
  600. customerName: this.searchForm.customerName,
  601. pageNum: 1,
  602. pageSize: 10,
  603. });
  604. },
  605. //重置
  606. clearFn() {
  607. console.log(this.$refs.searchForm);
  608. this.$refs.searchForm.resetFields();
  609. },
  610. //获取列表数据
  611. async getList(data) {
  612. const res = await getDealerStockList(data);
  613. this.dataList = res.data.records;
  614. this.listTotal = res.data.total;
  615. },
  616. },
  617. };
  618. </script>
  619. <style lang="scss" scoped>
  620. .add-right {
  621. margin-right: 10px;
  622. }
  623. // ::v-deep .selectStyle .el-input--suffix {
  624. // width: 200%;
  625. // }
  626. // ::v-deep .el-input--suffix {
  627. // width: 300px;
  628. // }
  629. // ::v-deep .el-dialog__header {
  630. // background-color: #dddddd;
  631. // }
  632. // ::v-deep .dialog-footer {
  633. // display: flex;
  634. // justify-content: center;
  635. // }
  636. // .formWidth {
  637. // width: 70%;
  638. // margin-right: 20px;
  639. // }
  640. .selectStyle {
  641. width: 100%;
  642. }
  643. </style>