warehouse_book.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <template>
  2. <div class="app-container">
  3. <div class="btn-group clearfix">
  4. <div class="fl">
  5. <el-button
  6. v-if="$checkBtnRole('add', $route.meta.roles)"
  7. type="primary"
  8. icon="el-icon-plus"
  9. size="small"
  10. @click="dialogVisible=true;type=1"
  11. >新增</el-button>
  12. </div>
  13. </div>
  14. <el-card class="box-card">
  15. <div slot="header" class="clearfix">
  16. <span>仓库每天预约提货设置</span>
  17. </div>
  18. <!-- 列表 -->
  19. <div class="">
  20. <el-table
  21. v-loading="listLoading"
  22. :data="dataList"
  23. element-loading-text="Loading"
  24. border
  25. fit
  26. highlight-current-row
  27. stripe
  28. >
  29. <el-table-column
  30. align="center"
  31. label="序号"
  32. type="index"
  33. min-width="60"
  34. show-overflow-tooltip
  35. />
  36. <el-table-column
  37. align="center"
  38. label="仓库"
  39. prop="correspondName"
  40. min-width="160"
  41. show-overflow-tooltip
  42. />
  43. <el-table-column
  44. align="center"
  45. label="预约存货类型"
  46. prop="categoryName"
  47. min-width="160"
  48. show-overflow-tooltip
  49. />
  50. <el-table-column
  51. align="center"
  52. label="最大预约单量(1天)"
  53. prop="number"
  54. min-width="160"
  55. show-overflow-tooltip
  56. >
  57. <template slot-scope="scope">
  58. <el-input v-model.number="scope.row.number" type="number" :disabled="scope.row.isDisabled" />
  59. </template>
  60. </el-table-column>
  61. <el-table-column
  62. align="center"
  63. label="最大预约台数(1天)"
  64. prop="towerNum"
  65. min-width="160"
  66. show-overflow-tooltip
  67. >
  68. <template slot-scope="scope">
  69. <el-input v-model.number="scope.row.towerNum" type="number" :disabled="scope.row.isDisabled" />
  70. </template>
  71. </el-table-column>
  72. <el-table-column
  73. align="center"
  74. label="操作"
  75. min-width="160"
  76. show-overflow-tooltip
  77. >
  78. <template slot-scope="scope">
  79. <el-button
  80. type="text"
  81. class="textColor"
  82. @click="hanleEidt(scope.row.id,scope.row)"
  83. >编辑</el-button>
  84. <!-- <el-button type="text" class="textColor" @click="hanleSave(scope.row)">保存</el-button>-->
  85. </template>
  86. </el-table-column>
  87. </el-table>
  88. </div>
  89. </el-card>
  90. <el-dialog
  91. :visible.sync="dialogVisible"
  92. width="50%"
  93. :close-on-click-modal="false"
  94. @close="resetForm"
  95. >
  96. <el-form ref="ruleForm" :rules="rulue" :model="ruleForm" status-icon label-width="100px" class="demo-ruleForm" size="small">
  97. <el-form-item label="仓库" prop="correspondId">
  98. <el-select v-model="ruleForm.correspondId" filterable placeholder="请选择仓库" class="select" @change="handleStock">
  99. <el-option
  100. v-for="item in stockList"
  101. :key="item.id"
  102. :label="item.name"
  103. :value="item.id"
  104. />
  105. </el-select>
  106. </el-form-item>
  107. <el-form-item label="存货" prop="categoryId">
  108. <el-select v-model="ruleForm.categoryId" filterable placeholder="请选择存货" class="select" @change="handleCategory">
  109. <el-option
  110. v-for="item in cateList"
  111. :key="item.id"
  112. :label="item.name"
  113. :value="item.id"
  114. />
  115. </el-select>
  116. </el-form-item>
  117. <el-form-item label="预约单量" prop="number">
  118. <el-input v-model="ruleForm.number" placeholder="请输入最大预约单量" />
  119. </el-form-item>
  120. <el-form-item label="台数量" prop="towerNum">
  121. <el-input v-model="ruleForm.towerNum" placeholder="请输入预约台数量" />
  122. </el-form-item>
  123. </el-form>
  124. <span slot="footer" class="dialog-footer">
  125. <el-button @click="dialogVisible = false;resetForm()">取 消</el-button>
  126. <el-button type="primary" @click="handleAddInfo">确 定</el-button>
  127. </span>
  128. </el-dialog>
  129. </div>
  130. </template>
  131. <script>
  132. import Mixin from '@/mixin/index'
  133. // updateReserve getListStock categoryList
  134. import { addReserve, categoryList, getListReserve, getListStock, updateReserve } from '@/api/basic_data/warehouse'
  135. export default {
  136. mixins: [Mixin],
  137. data() {
  138. return {
  139. dialogVisible: false,
  140. dataList: [],
  141. index: 0,
  142. ruleForm: {
  143. 'categoryId': '',
  144. 'categoryName': '',
  145. 'correspondId': '',
  146. 'correspondName': '',
  147. 'id': '',
  148. 'number': '',
  149. 'towerNum': ''
  150. },
  151. stockList: [],
  152. cateList: [],
  153. rulue: {
  154. correspondId: [
  155. { required: true, message: '请选择仓库', trigger: 'change' }
  156. ],
  157. categoryId: [
  158. { required: true, message: '请选择存货', trigger: 'change' }
  159. ],
  160. number: [
  161. { required: true, message: '请输入最大预约单量', trigger: 'blur' }
  162. ],
  163. towerNum: [
  164. { required: true, message: '请输入预约台数量', trigger: 'blur' }
  165. ]
  166. },
  167. type: '',
  168. editData: {
  169. }
  170. }
  171. },
  172. created() {
  173. this.getList()
  174. this.getCommonList()
  175. },
  176. methods: {
  177. hanleEidt(id, row) {
  178. this.type = 2
  179. this.dialogVisible = true
  180. this.ruleForm = {
  181. ...row
  182. }
  183. // this.dataList.forEach(e => {
  184. // e.isDisabled = true
  185. // })
  186. // this.dataList[i].isDisabled = false
  187. },
  188. hanleSave(row) {
  189. const params = {
  190. ...row
  191. }
  192. addReserve(params).then(res => {
  193. this.$successMsg('保存成功')
  194. this.dataList.forEach(e => {
  195. e.isDisabled = true
  196. })
  197. })
  198. },
  199. handleAddInfo() {
  200. this.$refs.ruleForm.validate((valid) => {
  201. console.log(
  202. this.ruleForm
  203. )
  204. if (valid) {
  205. if (this.type === 1) {
  206. addReserve({
  207. ...this.ruleForm
  208. }).then(res => {
  209. this.$successMsg('新增成功')
  210. this.getList()
  211. })
  212. } else {
  213. updateReserve({
  214. ...this.ruleForm
  215. }).then(res => {
  216. this.$successMsg('编辑成功')
  217. this.getList()
  218. })
  219. }
  220. } else {
  221. console.log('error submit!!')
  222. return false
  223. }
  224. this.dialogVisible = false
  225. this.resetForm()
  226. })
  227. },
  228. resetForm() {
  229. this.$refs.ruleForm.resetFields()
  230. this.ruleForm = {
  231. 'categoryId': '',
  232. 'categoryName': '',
  233. 'correspondId': '',
  234. 'correspondName': '',
  235. 'id': '',
  236. 'number': '',
  237. 'towerNum': ''
  238. }
  239. },
  240. getList() {
  241. this.listLoading = true
  242. const params = {
  243. pageNum: this.currentPage,
  244. pageSize: this.pageSize
  245. }
  246. getListReserve(params).then((res) => {
  247. res.data.records.forEach(el => {
  248. el.isDisabled = true
  249. })
  250. this.dataList = res.data.records
  251. this.listTotal = res.data.total
  252. this.listLoading = false
  253. console.log(this.dataList, 1233)
  254. })
  255. },
  256. getCommonList() {
  257. getListStock({
  258. pageNum: 1,
  259. pageSize: -1,
  260. name: '',
  261. stockName: ''
  262. }).then(res => {
  263. this.stockList = res.data.records
  264. })
  265. categoryList({
  266. pageNum: 1,
  267. pageSize: -1,
  268. keyword: ''
  269. }).then(res => {
  270. console.log(res)
  271. this.cateList = res.data.records
  272. })
  273. },
  274. handleStock(e) {
  275. this.ruleForm.correspondName = this.stockList.filter(k => {
  276. return e === k.id
  277. })[0].name
  278. },
  279. handleCategory(e) {
  280. this.ruleForm.categoryName = this.cateList.filter(k => {
  281. return e === k.id
  282. })[0].name
  283. }
  284. }
  285. }
  286. </script>
  287. <style lang="scss" scoped>
  288. .btn-group{
  289. margin: 20px 0;
  290. }
  291. .select{
  292. width: 100%;
  293. }
  294. </style>