warehouse_site.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. <template>
  2. <div class="app-container">
  3. <!-- 筛选条件 -->
  4. <div>
  5. <el-form
  6. ref="screenForm"
  7. :model="screenForm"
  8. label-width="70px"
  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="name">
  15. <el-input
  16. placeholder="请输入仓库名称"
  17. v-model="screenForm.name"
  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="stockName">
  23. <el-input
  24. placeholder="请输入仓位名称"
  25. v-model="screenForm.stockName"
  26. ></el-input>
  27. </el-form-item>
  28. </el-col>
  29. <el-col :xs="24" :sm="12" :lg="12" class="tr">
  30. <el-form-item label="">
  31. <el-button size="small" @click="resetScreenForm">清空</el-button>
  32. <el-button size="small" type="primary" @click="submitScreenForm"
  33. >搜索</el-button
  34. >
  35. </el-form-item>
  36. </el-col>
  37. </el-row>
  38. </el-form>
  39. </div>
  40. <!-- 按钮 -->
  41. <div class="btn-group clearfix">
  42. <div class="fl">
  43. <el-button type="primary" icon="el-icon-plus" size="small" @click="newData(), (type = 1)" v-if="$checkBtnRole('add', $route.meta.roles)"
  44. >新增</el-button
  45. >
  46. <el-popconfirm
  47. confirm-button-text="好的"
  48. cancel-button-text="不用了"
  49. icon="el-icon-info"
  50. icon-color="red"
  51. title="内容确定删除吗?"
  52. @onConfirm="handleDeleteAll"
  53. v-if="$checkBtnRole('del', $route.meta.roles)"
  54. >
  55. <el-button
  56. slot="reference"
  57. type="primary"
  58. icon="el-icon-delete"
  59. size="small"
  60. class="textColor el-popover-left"
  61. >批量删除</el-button
  62. >
  63. </el-popconfirm>
  64. </div>
  65. </div>
  66. <div class="mymain-container">
  67. <!-- 列表 -->
  68. <div class="table">
  69. <el-table
  70. v-loading="listLoading"
  71. :data="dataList"
  72. element-loading-text="Loading"
  73. @select-all="hanleSelectAll"
  74. @select="hanleSelectAll"
  75. border
  76. fit
  77. highlight-current-row
  78. stripe
  79. >
  80. <el-table-column
  81. align="left"
  82. type="selection"
  83. width="55">
  84. </el-table-column>
  85. <el-table-column
  86. align="left"
  87. label="仓库名称"
  88. prop="name"
  89. min-width="160"
  90. show-overflow-tooltip
  91. ></el-table-column>
  92. <el-table-column
  93. align="left"
  94. label="仓位名称"
  95. prop="kingDeeStocks"
  96. min-width="400"
  97. show-overflow-tooltip
  98. >
  99. <template slot-scope="scope">
  100. <template v-if="scope.row.kingDeeStocks.length > 0">
  101. <el-tag
  102. type="danger"
  103. style="margin-right: 10px"
  104. v-for="item in scope.row.kingDeeStocks"
  105. >
  106. {{ item.name }}
  107. </el-tag>
  108. </template>
  109. </template>
  110. </el-table-column>
  111. <el-table-column
  112. align="left"
  113. label="库存警戒线"
  114. prop="stockCordon"
  115. min-width="160"
  116. show-overflow-tooltip
  117. ></el-table-column>
  118. <!-- <el-table-column
  119. align="left"
  120. label="库存充足"
  121. prop="status"
  122. min-width="160"
  123. show-overflow-tooltip
  124. >
  125. <template slot-scope="scope">
  126. <el-tag type="success" v-if="scope.row.status === 1">充足</el-tag>
  127. <el-tag type="danger" v-else>不充足</el-tag>
  128. </template>
  129. </el-table-column> -->
  130. <el-table-column
  131. align="left"
  132. label="创建人"
  133. prop="createBy"
  134. min-width="200"
  135. show-overflow-tooltip
  136. ></el-table-column>
  137. <el-table-column
  138. align="left"
  139. label="创建时间"
  140. prop="createTime"
  141. min-width="200"
  142. show-overflow-tooltip
  143. ></el-table-column>
  144. <el-table-column
  145. align="left"
  146. label="更新人"
  147. prop="updateBy"
  148. min-width="200"
  149. show-overflow-tooltip
  150. ></el-table-column>
  151. <el-table-column
  152. align="left"
  153. label="更新时间"
  154. prop="updateTime"
  155. min-width="200"
  156. show-overflow-tooltip
  157. >
  158. </el-table-column>
  159. <el-table-column
  160. align="center"
  161. fixed="right"
  162. label="操作"
  163. min-width="160"
  164. show-overflow-tooltip
  165. >
  166. <template slot-scope="scope">
  167. <!-- <el-button
  168. type="text"
  169. class="textColor"
  170. @click="hanleDetail(scope.row)"
  171. >详情</el-button
  172. > -->
  173. <el-button
  174. v-if="$checkBtnRole('edit', $route.meta.roles)"
  175. type="text"
  176. class="textColor"
  177. @click="editFn(scope.row.id, scope.row), (type = 2)"
  178. >编辑</el-button
  179. >
  180. <el-popconfirm
  181. v-if="$checkBtnRole('del', $route.meta.roles)"
  182. confirm-button-text="好的"
  183. cancel-button-text="不用了"
  184. icon="el-icon-info"
  185. icon-color="red"
  186. title="内容确定删除吗?"
  187. @onConfirm="hanleDelete(scope.row.id)"
  188. >
  189. <el-button
  190. slot="reference"
  191. type="text"
  192. class="textColor el-popover-left"
  193. >删除</el-button
  194. >
  195. </el-popconfirm>
  196. </template>
  197. </el-table-column>
  198. </el-table>
  199. </div>
  200. <!-- 分页 -->
  201. <div class="fr">
  202. <el-pagination
  203. @size-change="handleSizeChange"
  204. @current-change="handleCurrentChange"
  205. :current-page="currentPage"
  206. :page-sizes="[10, 20, 30, 50]"
  207. :page-size="10"
  208. layout="total, sizes, prev, pager, next, jumper"
  209. :total="listTotal"
  210. >
  211. </el-pagination>
  212. </div>
  213. </div>
  214. <!-- 弹窗 -->
  215. <el-dialog
  216. title="仓库仓位对应关系"
  217. :visible.sync="showDialogForm"
  218. width="30%"
  219. :show-close="false"
  220. :close-on-click-modal="false"
  221. >
  222. <el-form
  223. ref="diaLogForm"
  224. :model="diaLogForm"
  225. label-width="70px"
  226. size="small"
  227. label-position="left"
  228. >
  229. <el-form-item label="仓库名称">
  230. <el-input v-model="diaLogForm.name"></el-input>
  231. </el-form-item>
  232. <el-form-item label="仓位名称">
  233. <el-select
  234. v-model="diaLogForm.stockIds"
  235. multiple
  236. filterable
  237. placeholder="请选择"
  238. >
  239. <el-option
  240. v-for="item in cList"
  241. :key="item.id"
  242. :label="item.name"
  243. :value="item.id"
  244. >
  245. </el-option>
  246. </el-select>
  247. </el-form-item>
  248. <el-form-item label="库存警戒线">
  249. <el-input v-model="diaLogForm.stockCordon"></el-input>
  250. </el-form-item>
  251. <!-- <el-form-item label="库存状态">
  252. <el-radio v-model="diaLogForm.status" label="1">充足</el-radio>
  253. <el-radio v-model="diaLogForm.status" label="2">补充足</el-radio>
  254. </el-form-item> -->
  255. <el-form-item label="备注">
  256. <el-input type="textarea" v-model="diaLogForm.remark"></el-input>
  257. </el-form-item>
  258. <el-form-item label="虚拟仓">
  259. <el-radio v-model="diaLogForm.type" label="2">是</el-radio>
  260. <el-radio v-model="diaLogForm.type" label="1">否</el-radio>
  261. </el-form-item>
  262. </el-form>
  263. <div slot="footer" class="dialog-footer">
  264. <el-button @click="showDialogForm = false">取 消</el-button>
  265. <el-button type="primary" @click="hanleInfo">确 定</el-button>
  266. </div>
  267. </el-dialog>
  268. </div>
  269. </template>
  270. <script>
  271. import Mixin from '@/mixin/index'
  272. import { addStock, deleteStock, getList, getListStock, updateStock } from '@/api/basic_data/warehouse'
  273. export default {
  274. mixins: [Mixin],
  275. data() {
  276. return {
  277. currentPage: 1, // 当前页码
  278. pageSize: 10, // 每页数量
  279. listTotal: 0, // 列表总数
  280. options: [
  281. {
  282. value: "选项1",
  283. label: "1",
  284. },
  285. {
  286. value: "选项2",
  287. label: "2",
  288. },
  289. {
  290. value: "选项3",
  291. label: "3",
  292. },
  293. {
  294. value: "选项4",
  295. label: "4",
  296. },
  297. {
  298. value: "选项5",
  299. label: "5",
  300. },
  301. ],
  302. diaLogForm: {
  303. id: null,
  304. type:'1',
  305. name: "",
  306. remark: "",
  307. status: 1,
  308. stockCordon: 0,
  309. stockIds: [],
  310. updateBy: "",
  311. updateTime: "",
  312. },
  313. showDialogForm: false,
  314. screenForm: {
  315. name: "",
  316. stockName: "",
  317. },
  318. screenForm2: {
  319. // 筛选表单数据
  320. name: "", // 名称
  321. },
  322. type: null,
  323. cList: {},
  324. };
  325. },
  326. methods: {
  327. newData() {
  328. this.showDialogForm = true;
  329. this.type = 1;
  330. const params = {
  331. pageNum: 1,
  332. pageSize: -1,
  333. name: "",
  334. };
  335. getList(params).then((res) => {
  336. this.cList = res.data.records;
  337. this.listTotal = res.data.total;
  338. });
  339. },
  340. //显示编辑,编辑数据初始化
  341. editFn(id, row) {
  342. this.type = 2;
  343. const arr = [];
  344. if (row.kingDeeStocks.length > 0) {
  345. row.kingDeeStocks.forEach((el) => {
  346. arr.push(el.id);
  347. });
  348. }
  349. this.newData();
  350. console.log(row.type,'444')
  351. this.diaLogForm = {
  352. id,
  353. name: row.name,
  354. remark: row.remark,
  355. status: row.status,
  356. stockCordon: row.stockCordon,
  357. type:row.type+'',
  358. stockIds: row.stockIds === undefined ? arr : row.stockIds,
  359. };
  360. this.showDialogForm = true;
  361. },
  362. hanleInfo() {
  363. console.log(this.type);
  364. if (this.type == 1) {
  365. addStock(this.diaLogForm).then((res) => {
  366. this.$successMsg("保存成功");
  367. this.showDialogForm = false;
  368. this.getList();
  369. });
  370. } else if (this.type == 2) {
  371. const params = {
  372. ...this.diaLogForm,
  373. };
  374. updateStock(params).then((res) => {
  375. this.$successMsg("编辑成功");
  376. this.showDialogForm = false;
  377. this.getList();
  378. });
  379. }
  380. this.diaLogForm = {
  381. name: "",
  382. remark: "",
  383. type:'1',
  384. status: 0,
  385. stockCordon: 0,
  386. stockIds: [],
  387. updateBy: "",
  388. updateTime: "",
  389. };
  390. },
  391. getList() {
  392. this.listLoading = true;
  393. let params = {
  394. pageNum: this.currentPage,
  395. pageSize: this.pageSize,
  396. name: this.screenForm.name,
  397. stockName: this.screenForm.stockName,
  398. };
  399. getListStock(params).then((res) => {
  400. this.dataList = res.data.records;
  401. this.listTotal = res.data.total;
  402. this.listLoading = false;
  403. console.log(this.dataList, 1233);
  404. });
  405. },
  406. // 删除数据
  407. hanleDelete(id) {
  408. deleteStock({id:[id].join('')} ).then((res) => {
  409. this.$successMsg("删除成功");
  410. this.getList();
  411. });
  412. },
  413. handleDeleteAll(){
  414. console.log();
  415. deleteStock({id:this.ids.join(',')} ).then((res) => {
  416. this.$successMsg("删除成功");
  417. this.getList();
  418. });
  419. }
  420. },
  421. };
  422. </script>
  423. <style lang="scss" scoped>
  424. ::v-deep .el-date-editor {
  425. width: 100%;
  426. }
  427. ::v-deep .el-select {
  428. width: 100%;
  429. }
  430. ::v-deep .el-col-9 .el-button {
  431. padding: 5px;
  432. }
  433. ::v-deep .el-dialog__header {
  434. background-color: #dddddd;
  435. }
  436. .base {
  437. padding: 20px 20px 0;
  438. }
  439. .table {
  440. margin-top: 12px;
  441. }
  442. .right {
  443. float: right;
  444. }
  445. </style>