|
@@ -25,7 +25,7 @@
|
|
|
<el-table v-loading="loading" :data="dataList" border highlight-current-row>
|
|
|
<el-table-column label="库位" prop="locationName" width="200"></el-table-column>
|
|
|
<el-table-column label="公司部门" prop="deptName" width="300"></el-table-column>
|
|
|
- <el-table-column label="保管员" prop="deptNames" width="200"></el-table-column>
|
|
|
+ <el-table-column label="保管员" prop="keeperName" width="200"></el-table-column>
|
|
|
<el-table-column label="描述" prop="remark" />
|
|
|
<el-table-column label="操作" class-name="small-padding fixed-width" width="300" align="center">
|
|
|
<template slot-scope="scope">
|
|
@@ -53,152 +53,169 @@
|
|
|
<el-button type="primary" size="small" @click="stockSub">保 存</el-button>
|
|
|
</div>
|
|
|
</el-dialog>
|
|
|
- <UserChoice />
|
|
|
+ <UserChoice ref="userChoice" @selectedPerson="selectedPerson"/>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- import { stockList, stockAdd, stockUpd, stockDel } from '@/api/system/stockLocation.js'
|
|
|
- import TreeChoice from '@/components/deptTreeChoice/index.vue'
|
|
|
- import UserChoice from '@/components/userChoice/index.vue'
|
|
|
- export default {
|
|
|
- name: 'stockLocation',
|
|
|
- components: {
|
|
|
- TreeChoice,
|
|
|
- UserChoice
|
|
|
+import { stockList, stockAdd, stockUpd, stockDel, updateKeeper } from '@/api/system/stockLocation.js'
|
|
|
+import { treeselect } from '@/api/system/dept'
|
|
|
+import TreeChoice from '@/components/deptTreeChoice/index.vue'
|
|
|
+import UserChoice from '@/components/userChoice/index.vue'
|
|
|
+export default {
|
|
|
+ name: 'stockLocation',
|
|
|
+ components: {
|
|
|
+ TreeChoice,
|
|
|
+ UserChoice
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ loading: false,
|
|
|
+ //拥有权限的部门id数组
|
|
|
+ hasDeptIds: [],
|
|
|
+ //数据
|
|
|
+ dataList: [],
|
|
|
+ //库位编辑弹窗显示
|
|
|
+ stockShow: false,
|
|
|
+ //库位编辑弹窗标题
|
|
|
+ title: '',
|
|
|
+ // 部门信息
|
|
|
+ deptOptions: [],
|
|
|
+ //库位表单
|
|
|
+ stockForm: { deptId: '', locationName: '', remark: '', deptName: '' },
|
|
|
+ //库位表单验证
|
|
|
+ stockRules: { locationName: [{ required: true, message: '名称不能为空', trigger: 'blur' }] },
|
|
|
+ locationId: '', // 库位id
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ //获取数据
|
|
|
+ getList() {
|
|
|
+ if (!this.hasDeptIds.length) {
|
|
|
+ this.dataList = []
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.loading = true
|
|
|
+ stockList({ deptIds: this.hasDeptIds }).then((res) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.dataList = res.data
|
|
|
+ this.loading = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //获取部门信息
|
|
|
+ getDeptInfo(d) {
|
|
|
+ this.stockForm.deptId = d.deptId
|
|
|
+ this.stockForm.deptName = d.deptName
|
|
|
},
|
|
|
- data() {
|
|
|
- return {
|
|
|
- loading: false,
|
|
|
- //拥有权限的部门id数组
|
|
|
- hasDeptIds: [],
|
|
|
- //数据
|
|
|
- dataList: [],
|
|
|
- //库位编辑弹窗显示
|
|
|
- stockShow: false,
|
|
|
- //库位编辑弹窗标题
|
|
|
- title: '',
|
|
|
- //库位表单
|
|
|
- stockForm: { deptId: '', locationName: '', remark: '', deptName: '' },
|
|
|
- //库位表单验证
|
|
|
- stockRules: { locationName: [{ required: true, message: '名称不能为空', trigger: 'blur' }] }
|
|
|
+ //显示库位弹窗
|
|
|
+ addStockShow() {
|
|
|
+ this.title = '库位添加'
|
|
|
+ this.stockShow = true
|
|
|
+ },
|
|
|
+ //表单重置
|
|
|
+ resetForm() {
|
|
|
+ this.stockForm = { deptId: '', locationName: '', remark: '', deptName: '' }
|
|
|
+ },
|
|
|
+ //检测重名
|
|
|
+ checkName(data) {
|
|
|
+ let o = this.dataList.find((item) => item.locationName == data.locationName && item.locationId != data.locationId)
|
|
|
+ if (o) {
|
|
|
+ return '库位名称重复'
|
|
|
}
|
|
|
+ return false
|
|
|
},
|
|
|
- methods: {
|
|
|
- //获取数据
|
|
|
- getList() {
|
|
|
- if (!this.hasDeptIds.length) {
|
|
|
- this.dataList = []
|
|
|
- return
|
|
|
- }
|
|
|
- this.loading = true
|
|
|
- stockList({ deptIds: this.hasDeptIds }).then((res) => {
|
|
|
- if (res.code === 200) {
|
|
|
- this.dataList = res.data
|
|
|
- this.loading = false
|
|
|
+ //库位弹窗取消
|
|
|
+ stockCancel() {
|
|
|
+ this.resetForm()
|
|
|
+ this.stockShow = false
|
|
|
+ },
|
|
|
+ //库位弹窗提交
|
|
|
+ stockSub() {
|
|
|
+ this.$refs.stockForm.validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ let checkFiled = this.checkName(this.stockForm)
|
|
|
+ if (checkFiled) {
|
|
|
+ this.$msg({ type: 'error', message: checkFiled })
|
|
|
+ return
|
|
|
}
|
|
|
- })
|
|
|
- },
|
|
|
- //获取部门信息
|
|
|
- getDeptInfo(d) {
|
|
|
- this.stockForm.deptId = d.deptId
|
|
|
- this.stockForm.deptName = d.deptName
|
|
|
- },
|
|
|
- //显示库位弹窗
|
|
|
- addStockShow() {
|
|
|
- this.title = '库位添加'
|
|
|
- this.stockShow = true
|
|
|
- },
|
|
|
- //表单重置
|
|
|
- resetForm() {
|
|
|
- this.stockForm = { deptId: '', locationName: '', remark: '', deptName: '' }
|
|
|
- },
|
|
|
- //检测重名
|
|
|
- checkName(data) {
|
|
|
- let o = this.dataList.find((item) => item.locationName == data.locationName && item.locationId != data.locationId)
|
|
|
- if (o) {
|
|
|
- return '库位名称重复'
|
|
|
- }
|
|
|
- return false
|
|
|
- },
|
|
|
- //库位弹窗取消
|
|
|
- stockCancel() {
|
|
|
- this.resetForm()
|
|
|
- this.stockShow = false
|
|
|
- },
|
|
|
- //库位弹窗提交
|
|
|
- stockSub() {
|
|
|
- this.$refs.stockForm.validate((valid) => {
|
|
|
- if (valid) {
|
|
|
- let checkFiled = this.checkName(this.stockForm)
|
|
|
- if (checkFiled) {
|
|
|
- this.$msg({ type: 'error', message: checkFiled })
|
|
|
- return
|
|
|
- }
|
|
|
- if (this.stockForm.locationId) {
|
|
|
- stockUpd(this.stockForm).then((res) => {
|
|
|
- if (res.code === 200) {
|
|
|
- this.$msg({ message: '修改成功' })
|
|
|
- this.dataList = this.dataList.map((item) => {
|
|
|
- if (item.locationId == this.stockForm.locationId) {
|
|
|
- return {
|
|
|
- ...item,
|
|
|
- ...this.stockForm
|
|
|
- }
|
|
|
- }
|
|
|
+ if (this.stockForm.locationId) {
|
|
|
+ stockUpd(this.stockForm).then((res) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.$msg({ message: '修改成功' })
|
|
|
+ this.dataList = this.dataList.map((item) => {
|
|
|
+ if (item.locationId == this.stockForm.locationId) {
|
|
|
return {
|
|
|
- ...item
|
|
|
+ ...item,
|
|
|
+ ...this.stockForm
|
|
|
}
|
|
|
- })
|
|
|
- this.stockCancel()
|
|
|
- }
|
|
|
- })
|
|
|
- } else {
|
|
|
- stockAdd(this.stockForm).then((res) => {
|
|
|
- if (res.code === 200) {
|
|
|
- this.$msg({ message: '添加成功' })
|
|
|
- this.getList()
|
|
|
- this.stockCancel()
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- //选择人员
|
|
|
- choiceUser() {},
|
|
|
- //修改
|
|
|
- updStock(row) {
|
|
|
- this.stockForm = {
|
|
|
- deptId: row.deptId,
|
|
|
- locationName: row.locationName,
|
|
|
- remark: row.remark,
|
|
|
- deptName: row.deptName,
|
|
|
- locationId: row.locationId
|
|
|
- }
|
|
|
- this.title = '库位修改'
|
|
|
- this.stockShow = true
|
|
|
- },
|
|
|
- //删除
|
|
|
- delStock(row) {
|
|
|
- this.$modal
|
|
|
- .confirm('确定要删除吗')
|
|
|
- .then(() => {
|
|
|
- stockDel(row.locationId).then((res) => {
|
|
|
- if (res.code == 200) {
|
|
|
- this.$msg({ message: '删除成功' })
|
|
|
- this.dataList = this.dataList.filter((item) => item.locationId != row.locationId)
|
|
|
- } else {
|
|
|
- this.$msg({ type: 'error', message: res.msg })
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ ...item
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.stockCancel()
|
|
|
}
|
|
|
})
|
|
|
- })
|
|
|
- .catch(() => {})
|
|
|
+ } else {
|
|
|
+ stockAdd(this.stockForm).then((res) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.$msg({ message: '添加成功' })
|
|
|
+ this.getList()
|
|
|
+ this.stockCancel()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //选择人员
|
|
|
+ choiceUser(row) {
|
|
|
+ this.locationId = row.locationId
|
|
|
+ treeselect().then((response) => {
|
|
|
+ this.deptOptions = response.data
|
|
|
+ this.deptOptions.unshift({id: '0', label: '全部部门'})
|
|
|
+ this.$refs.userChoice.init(true, this.deptOptions)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //人员回调
|
|
|
+ selectedPerson(data) {
|
|
|
+ updateKeeper({keeper: data, locationId: this.locationId}).then(res => {
|
|
|
+ this.getList()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //修改
|
|
|
+ updStock(row) {
|
|
|
+ this.stockForm = {
|
|
|
+ deptId: row.deptId,
|
|
|
+ locationName: row.locationName,
|
|
|
+ remark: row.remark,
|
|
|
+ deptName: row.deptName,
|
|
|
+ locationId: row.locationId
|
|
|
}
|
|
|
+ this.title = '库位修改'
|
|
|
+ this.stockShow = true
|
|
|
+ },
|
|
|
+ //删除
|
|
|
+ delStock(row) {
|
|
|
+ this.$modal
|
|
|
+ .confirm('确定要删除吗')
|
|
|
+ .then(() => {
|
|
|
+ stockDel(row.locationId).then((res) => {
|
|
|
+ if (res.code == 200) {
|
|
|
+ this.$msg({ message: '删除成功' })
|
|
|
+ this.dataList = this.dataList.filter((item) => item.locationId != row.locationId)
|
|
|
+ } else {
|
|
|
+ this.$msg({ type: 'error', message: res.msg })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ .catch(() => {})
|
|
|
}
|
|
|
}
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style></style>
|