dealer_stock.vue 16 KB

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