dealer_stock.vue 17 KB

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