dealer_stock.vue 21 KB

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