warehouse_book.vue 8.2 KB

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