warehouse_site.vue 12 KB

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