dealer_stock.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  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="6">
  22. <el-form-item label="存货分类编码" prop="bianMa">
  23. <el-input
  24. v-model="searchForm.mainId"
  25. placeholder="请输入"
  26. ></el-input>
  27. </el-form-item>
  28. </el-col>
  29. <el-col :xs="24" :sm="12" :lg="6">
  30. <el-form-item label="存货分类" prop="mainName">
  31. <el-input
  32. v-model="searchForm.mainName"
  33. placeholder="请输入"
  34. ></el-input>
  35. </el-form-item>
  36. </el-col>
  37. <el-col :xs="24" :sm="12" :lg="6">
  38. <el-form-item label="" class="fr">
  39. <el-button size="small" @click="clearFn">清空</el-button>
  40. <el-button size="small" type="primary" @click="searchFn"
  41. >搜索</el-button
  42. >
  43. </el-form-item>
  44. </el-col>
  45. </el-row>
  46. </el-form>
  47. </div>
  48. <div class="btn-group clearfix">
  49. <div class="fl">
  50. <el-button type="primary" size="small" @click="addFn">新增</el-button>
  51. <el-button type="primary" size="small">编辑</el-button>
  52. <el-popconfirm @onConfirm="deleFn" title="这是一段内容确定删除吗?">
  53. <el-button
  54. type="primary"
  55. size="small"
  56. class="textColor"
  57. slot="reference"
  58. >删除</el-button
  59. >
  60. </el-popconfirm>
  61. </div>
  62. <div class="fr">
  63. <el-button type="primary" size="small">导入</el-button>
  64. <el-button type="primary" size="small">导出</el-button>
  65. <el-button type="primary" size="small">打印</el-button>
  66. </div>
  67. </div>
  68. <div class="mymain-container">
  69. <!-- 列表 -->
  70. <div class="table">
  71. <el-table
  72. v-loading="listLoading"
  73. :data="dataList"
  74. @select="hanleSelect"
  75. @select-all="hanleSelect"
  76. element-loading-text="Loading"
  77. border
  78. fit
  79. highlight-current-row
  80. stripe
  81. >
  82. <el-table-column
  83. type="selection"
  84. align="center"
  85. min-width="100"
  86. ></el-table-column>
  87. <el-table-column
  88. align="center"
  89. label="经销商名称"
  90. prop="customerName"
  91. min-width="160"
  92. show-overflow-tooltip
  93. ></el-table-column>
  94. <el-table-column
  95. align="center"
  96. label="存货分类编码"
  97. prop="mainId"
  98. min-width="160"
  99. show-overflow-tooltip
  100. ></el-table-column>
  101. <el-table-column
  102. align="center"
  103. label="存货分类名称"
  104. prop="mainName"
  105. min-width="160"
  106. show-overflow-tooltip
  107. ></el-table-column>
  108. <el-table-column
  109. align="center"
  110. label="创建人"
  111. prop="createBy"
  112. min-width="160"
  113. show-overflow-tooltip
  114. ></el-table-column>
  115. <el-table-column
  116. align="center"
  117. label="创建时间"
  118. prop="createTime"
  119. min-width="160"
  120. show-overflow-tooltip
  121. ></el-table-column>
  122. <el-table-column
  123. align="center"
  124. label="更新人"
  125. prop="updateBy"
  126. min-width="160"
  127. show-overflow-tooltip
  128. ></el-table-column>
  129. <el-table-column
  130. align="center"
  131. label="更新时间"
  132. prop="updateTime"
  133. min-width="160"
  134. show-overflow-tooltip
  135. ></el-table-column>
  136. <el-table-column
  137. align="center"
  138. label="操作"
  139. prop="caozuo"
  140. min-width="160"
  141. show-overflow-tooltip
  142. >
  143. <template slot-scope="scope">
  144. <el-button type="text" class="textColor">编辑</el-button>
  145. <el-popconfirm
  146. @onConfirm="deleFn(scope.row.id)"
  147. title="这是一段内容确定删除吗?"
  148. >
  149. <el-button type="text" class="textColor" slot="reference"
  150. >删除</el-button
  151. ></el-popconfirm
  152. >
  153. </template>
  154. </el-table-column>
  155. </el-table>
  156. </div>
  157. <!-- 分页 -->
  158. <div class="fr">
  159. <el-pagination
  160. @size-change="handleSizeChange"
  161. @current-change="handleCurrentChange"
  162. :current-page="currentPage"
  163. :page-sizes="[10, 20, 30, 50]"
  164. :page-size="10"
  165. layout="total, sizes, prev, pager, next, jumper"
  166. :total="listTotal"
  167. >
  168. </el-pagination>
  169. </div>
  170. </div>
  171. <!-- 弹窗 -->
  172. <el-dialog
  173. title="编辑"
  174. :visible.sync="dialogForm"
  175. width="30%"
  176. :show-close="false"
  177. :close-on-click-modal="false"
  178. >
  179. <el-form
  180. ref="addForm"
  181. :model="addForm"
  182. label-width="100px"
  183. label-position="right"
  184. >
  185. <el-form-item label="经销商名称">
  186. <el-select
  187. class="selectStyle"
  188. v-model="addForm.customerId"
  189. placeholder="名称"
  190. >
  191. <el-option
  192. v-for="item in dealerList"
  193. :key="item.id"
  194. :label="item.name"
  195. :value="item.id"
  196. >
  197. </el-option>
  198. </el-select>
  199. </el-form-item>
  200. <el-form-item label="存货分类">
  201. <el-select
  202. class="selectStyle"
  203. v-model="addForm.mainId"
  204. placeholder="请选择"
  205. >
  206. <el-option
  207. v-for="item in selectList"
  208. :key="item.value"
  209. :label="item.dictValue"
  210. :value="item.sysDictId"
  211. >
  212. </el-option>
  213. </el-select>
  214. </el-form-item>
  215. </el-form>
  216. <div slot="footer" class="dialog-footer">
  217. <el-button @click="dialogForm = false">取 消</el-button>
  218. <el-button type="primary" @click="addDataListFn">确 定</el-button>
  219. </div>
  220. </el-dialog>
  221. </div>
  222. </template>
  223. <script>
  224. import {
  225. getDealerStockList,
  226. getDealerStockAdd,
  227. deleDealerStockList,
  228. getDictionaries,
  229. } from "@/api/basic_data/dealer";
  230. import { getDealerList } from "@/api/basic_data/dealer";
  231. import { findElem } from "@/utils/util";
  232. export default {
  233. data() {
  234. return {
  235. dialogForm: false,
  236. addForm: {
  237. customerName: "",
  238. customerId: "",
  239. customerNumber: "",
  240. mainId: "",
  241. mainName: "",
  242. },
  243. currentPage: 1, // 当前页码
  244. pageSize: 10, // 每页数量
  245. listTotal: 0, // 列表总数
  246. searchForm: {
  247. customerName: "",
  248. mainId: "",
  249. mainName: "",
  250. },
  251. dataList: [], // 列表数据
  252. listLoading: false, // 列表加载loading
  253. dealerList: [],
  254. selectList: [],
  255. ids: [],
  256. };
  257. },
  258. async created() {
  259. this.getList({ pageNum: 1, pageSize: 10 });
  260. this.getDealerDataList({ pageNum: 1, pageSize: 10 });
  261. this.getSelectList({ sysDictEnum: "PRODUCT_TYPE" });
  262. },
  263. computed: {},
  264. methods: {
  265. // 筛选部分数据或者单个
  266. hanleSelect(selection) {
  267. // this.ids = selection.map((k) => {
  268. // return k.id;
  269. // });
  270. console.log(selection);
  271. this.ids = selection.map((v) => v.id);
  272. },
  273. //存货分类
  274. async getSelectList(data) {
  275. const res = await getDictionaries(data);
  276. console.log(res);
  277. this.selectList = res.data;
  278. },
  279. //删除
  280. async deleFn(id) {
  281. this.ids.push(id);
  282. let res = this.ids.toString();
  283. await deleDealerStockList({ ids: res });
  284. this.getList({ pageNum: 1, pageSize: 10 });
  285. this.$message.success("删除成功");
  286. },
  287. addFn() {
  288. this.dialogForm = true;
  289. },
  290. async addDataListFn() {
  291. console.log(this.dealerList);
  292. console.log(this.addForm.customerId);
  293. // let id = this.dealerList.filter((i) => {
  294. // return i.id === this.addForm.customerId;
  295. // })[0];
  296. // console.log(id, "id");
  297. // let res = findElem(this.dealerList, "id", this.addForm.customerId);
  298. // console.log(11111, res);
  299. let res = this.dealerList.filter(
  300. (v) => v.id === this.addForm.customerId
  301. )[0];
  302. console.log(res);
  303. this.addForm.customerName = res.name;
  304. this.addForm.customerNumber = res.number;
  305. let res2 = this.selectList.filter(
  306. (v) => v.sysDictId === this.addForm.mainId
  307. )[0];
  308. console.log(res2);
  309. this.addForm.mainName = res2.dictValue;
  310. console.log(this.addForm);
  311. await getDealerStockAdd({ ...this.addForm });
  312. this.$message.success("添加成功");
  313. await this.getList({ pageNum: 1, pageSize: 10 });
  314. this.dialogForm = false;
  315. },
  316. //获取经销商数据
  317. async getDealerDataList(data) {
  318. const res = await getDealerList(data);
  319. this.dealerList = res.data.records;
  320. },
  321. // 更改每页数量
  322. handleSizeChange(val) {
  323. this.pageSize = val;
  324. this.currentPage = 1;
  325. this.getList({ pageNum: 1, pageSize: this.pageSize });
  326. },
  327. // 更改当前页
  328. handleCurrentChange(val) {
  329. this.currentPage = val;
  330. this.getList({ pageNum: val, pageSize: 10 });
  331. },
  332. //搜索功能
  333. async searchFn() {
  334. console.log(this.searchForm);
  335. await this.getList({
  336. cusotmerName: this.searchForm.customerName,
  337. pageNum: 1,
  338. pageSize: 10,
  339. });
  340. },
  341. //重置
  342. clearFn() {
  343. console.log(this.$refs.searchForm);
  344. this.$refs.searchForm.resetFields();
  345. },
  346. //获取列表数据
  347. async getList(data) {
  348. const res = await getDealerStockList(data);
  349. console.log(res);
  350. this.dataList = res.data.records;
  351. this.listTotal = res.data.total;
  352. },
  353. },
  354. };
  355. </script>
  356. <style lang="scss" scoped>
  357. ::v-deep .el-popover__reference {
  358. margin-left: 10px;
  359. }
  360. ::v-deep .selectStyle .el-input--suffix {
  361. width: 200%;
  362. }
  363. ::v-deep .el-input--suffix {
  364. width: 300px;
  365. }
  366. ::v-deep .el-dialog__header {
  367. background-color: #dddddd;
  368. }
  369. ::v-deep .dialog-footer {
  370. display: flex;
  371. justify-content: center;
  372. }
  373. .formWidth {
  374. width: 70%;
  375. margin-right: 20px;
  376. }
  377. </style>