区县物资

master
lion 4 months ago
parent 2daf9eef83
commit 952e661238

@ -1,17 +1,8 @@
# just a flag
ENV='development'
#VUE_APP_BASE_API = http://192.168.60.99:8004/
VUE_APP_UPLOAD_API = http://192.168.60.99:8004/api/admin/upload-file
VUE_APP_OA_URL= http://192.168.60.18:8001
VUE_APP_OA_URL_TYPE = '{"采购入库":51,"请示入库":54,"调拨入库":55,"领用出库":56,"处置出库":57,"调令出库":53}'
#正式
VUE_APP_BASE_API = http://192.168.60.99:8004
#VUE_APP_UPLOAD_API = http://192.168.60.99:9004/api/admin/upload-file
# 正式oa
#VUE_APP_OA_URL = http://192.168.60.18:2021
#VUE_APP_OA_URL_TYPE = '{"采购入库":51,"请示入库":54,"调拨入库":55,"领用出库":56,"处置出库":57,"调令出库":53}'
# 本地开发环境配置
VUE_APP_BASE_API=http://wzgl.localhost/
VUE_APP_UPLOAD_API=http://wzgl.localhost/api/admin/upload-file
VUE_APP_OA_URL=http://192.168.60.18:8001
VUE_APP_OA_URL_TYPE='{"采购入库":51,"请示入库":54,"调拨入库":55,"领用出库":56,"处置出库":57,"调令出库":53}'

@ -18,7 +18,8 @@ const getDefaultState = () => {
token: getToken(),
name: '',
avatar: '',
roles: []
roles: [],
area_id: null
}
}
@ -39,6 +40,9 @@ const mutations = {
},
SET_ROLES: (state, roles) => {
state.roles = roles
},
SET_AREA_ID: (state, area_id) => {
state.area_id = area_id
}
}
@ -48,7 +52,7 @@ const actions = {
}, userInfo) {
const {
token,
tp,
tp,
loginId
} = userInfo
@ -57,8 +61,8 @@ const actions = {
token: token,
tp: tp,
loginId: loginId
}).then(response => {
// console.log(response)
}).then(response => {
// console.log(response)
const {
data
@ -105,7 +109,7 @@ const actions = {
state
}) {
return new Promise((resolve, reject) => {
getInfo(state.token).then(response => {
getInfo(state.token).then(response => {
if (!response) {
reject('身份验证失败请重新登录')
}
@ -113,12 +117,14 @@ const actions = {
const {
roles,
name,
avatar
avatar,
area_id
} = response
commit('SET_ROLES', roles)
commit('SET_NAME', name)
commit('SET_AVATAR', avatar)
commit('SET_AREA_ID', area_id)
resolve(response)
}).catch(error => {
reject(error)
@ -131,7 +137,7 @@ const actions = {
commit,
state
}) {
return new Promise((resolve, reject) => {
return new Promise((resolve, reject) => {
console.log('logout', state.token)
logout(state.token).then(() => {
removeToken() // must remove token first
@ -161,4 +167,4 @@ export default {
state,
mutations,
actions
}
}

@ -282,40 +282,43 @@ export default {
})
},
async getDetail() {
const res = await show({
id: this.id,
table_name: this.tableName
})
this.form = {
rukuriqi: res?.rukuriqi || '',
jingbanren: res?.jingbanren || '',
fujian: res?.fujian ? (Array.isArray(res.fujian) ? res.fujian : JSON.parse(res.fujian)) : [],
beizhu: res?.beizhu || '',
rukuwuzi: res?.rukuwuzi ? (Array.isArray(res.rukuwuzi) ? res.rukuwuzi : JSON.parse(res.rukuwuzi)) : []
}
//
if (this.form.fujian && this.form.fujian.length > 0) {
// 使idfileList
this.fileList = this.form.fujian.map((id, index) => ({
id: id,
try {
const data = await show({
id: this.id,
table_name: this.tableName
}, true)
this.form = {
rukuriqi: data?.rukuriqi || '',
jingbanren: data?.jingbanren || '',
fujian: [],
beizhu: data?.beizhu || '',
rukuwuzi: []
}
if (data?.fujian) {
const f = data.fujian
this.form.fujian = Array.isArray(f) ? f : (typeof f === 'string' && f ? JSON.parse(f) : [])
}
this.fileList = (this.form.fujian || []).map((id, index) => ({
id: typeof id === 'object' ? id?.id : id,
name: `附件${index + 1}`,
url: ''
}))
}
//
if (res.rukuwuzi) {
try {
this.materialList = Array.isArray(res.rukuwuzi) ? res.rukuwuzi : JSON.parse(res.rukuwuzi)
} catch (e) {
this.materialList = []
}
} else {
this.materialList = []
if (data?.rukuwuzi) {
try {
const raw = typeof data.rukuwuzi === 'string' ? JSON.parse(data.rukuwuzi) : data.rukuwuzi
this.materialList = Array.isArray(raw) ? raw : []
} catch (e) {
this.materialList = []
}
}
} catch (e) {
Message({ type: 'error', message: '获取详情失败:' + (e?.message || '未知错误') })
this.resetForm()
}
},
submit() {
async submit() {
//
if (!this.materialList || this.materialList.length === 0) {
Message({
@ -334,35 +337,17 @@ export default {
rukuwuzi: JSON.stringify(this.materialList)
}
if (this.type === 'add') {
save(submitData).then(res => {
Message({
type: 'success',
message: '新增成功'
})
this.isShow = false
this.$emit('refresh')
}).catch(err => {
Message({
type: 'error',
message: '新增失败:' + (err.message || '未知错误')
})
})
} else if (this.type === 'editor') {
submitData.id = this.id
save(submitData).then(res => {
Message({
type: 'success',
message: '编辑成功'
})
this.isShow = false
this.$emit('refresh')
}).catch(err => {
Message({
type: 'error',
message: '编辑失败:' + (err.message || '未知错误')
})
})
const isAdd = this.type === 'add'
if (!isAdd) submitData.id = this.id
try {
await save(submitData)
Message({ type: 'success', message: isAdd ? '新增成功' : '编辑成功' })
this.isShow = false
this.$emit('refresh')
} catch (err) {
const msg = err?.response?.data?.errmsg || err?.message || '未知错误'
Message({ type: 'error', message: (isAdd ? '新增失败:' : '编辑失败:') + msg })
}
}
}

@ -305,39 +305,43 @@ export default {
})
},
async getDetail() {
const res = await show({
id: this.id,
table_name: this.tableName
})
this.form = {
chukuriqi: res?.chukuriqi || '',
jingbanren: res?.jingbanren || '',
fujian: res?.fujian ? (Array.isArray(res.fujian) ? res.fujian : JSON.parse(res.fujian)) : [],
beizhu: res?.beizhu || '',
chukuwuzi: res?.chukuwuzi ? (Array.isArray(res.chukuwuzi) ? res.chukuwuzi : JSON.parse(res.chukuwuzi)) : []
}
//
if (this.form.fujian && this.form.fujian.length > 0) {
this.fileList = this.form.fujian.map((id, index) => ({
id: id,
try {
const data = await show({
id: this.id,
table_name: this.tableName
}, true)
this.form = {
chukuriqi: data?.chukuriqi || '',
jingbanren: data?.jingbanren || '',
fujian: [],
beizhu: data?.beizhu || '',
chukuwuzi: []
}
if (data?.fujian) {
const f = data.fujian
this.form.fujian = Array.isArray(f) ? f : (typeof f === 'string' && f ? JSON.parse(f) : [])
}
this.fileList = (this.form.fujian || []).map((id, index) => ({
id: typeof id === 'object' ? id?.id : id,
name: `附件${index + 1}`,
url: ''
}))
}
//
if (res.chukuwuzi) {
try {
this.materialList = Array.isArray(res.chukuwuzi) ? res.chukuwuzi : JSON.parse(res.chukuwuzi)
} catch (e) {
this.materialList = []
}
} else {
this.materialList = []
if (data?.chukuwuzi) {
try {
const raw = typeof data.chukuwuzi === 'string' ? JSON.parse(data.chukuwuzi) : data.chukuwuzi
this.materialList = Array.isArray(raw) ? raw : []
} catch (e) {
this.materialList = []
}
}
} catch (e) {
Message({ type: 'error', message: '获取详情失败:' + (e?.message || '未知错误') })
this.resetForm()
}
},
submit() {
async submit() {
//
if (!this.materialList || this.materialList.length === 0) {
Message({
@ -376,35 +380,17 @@ export default {
chukuwuzi: JSON.stringify(this.materialList)
}
if (this.type === 'add') {
save(submitData).then(res => {
Message({
type: 'success',
message: '新增成功'
})
this.isShow = false
this.$emit('refresh')
}).catch(err => {
Message({
type: 'error',
message: '新增失败:' + (err.message || '未知错误')
})
})
} else if (this.type === 'editor') {
submitData.id = this.id
save(submitData).then(res => {
Message({
type: 'success',
message: '编辑成功'
})
this.isShow = false
this.$emit('refresh')
}).catch(err => {
Message({
type: 'error',
message: '编辑失败:' + (err.message || '未知错误')
})
})
const isAdd = this.type === 'add'
if (!isAdd) submitData.id = this.id
try {
await save(submitData)
Message({ type: 'success', message: isAdd ? '新增成功' : '编辑成功' })
this.isShow = false
this.$emit('refresh')
} catch (err) {
const msg = err?.response?.data?.errmsg || err?.message || '未知错误'
Message({ type: 'error', message: (isAdd ? '新增失败:' : '编辑失败:') + msg })
}
}
}

@ -74,9 +74,19 @@
import { index } from '@/api/system/baseForm.js'
import { index as getCangkuList } from '@/api/system/baseForm.js'
import { Message } from 'element-ui'
import { mapState } from 'vuex'
import { getparameteritem } from '@/api/system/dictionary.js'
export default {
name: 'SelectMaterial',
computed: {
...mapState('user', ['area_id']),
userAreaName() {
if (this.area_id == null || this.area_id === '') return ''
const area = (this.areaList || []).find(item => item.id == this.area_id)
return area ? area.value : ''
}
},
data() {
return {
isShow: false,
@ -84,6 +94,7 @@ export default {
materialList: [],
selectedMaterials: [], //
cangkuList: [],
areaList: [],
searchForm: {
keyword: '',
guanliancangku: ''
@ -97,23 +108,43 @@ export default {
},
created() {
this.getCangku()
this.getAreaList()
},
methods: {
async getAreaList() {
try {
const res = await getparameteritem('area')
this.areaList = res?.detail ?? []
} catch (e) {
this.areaList = []
}
},
async getCangku() {
const res = await getCangkuList({
page_size: 999,
page: 1,
table_name: 'materialstorages'
})
this.cangkuList = res.data || []
try {
const res = await getCangkuList({
page_size: 999,
page: 1,
table_name: 'materialstorages'
})
const list = res?.data ?? []
// area_id
if (this.area_id != null && this.area_id !== '') {
this.cangkuList = list.filter(item => item.quyu_id == this.area_id)
} else {
this.cangkuList = list
}
} catch (e) {
this.cangkuList = []
}
},
show() {
this.isShow = true
this.searchForm = {
keyword: '',
guanliancangku: ''
}
this.searchForm = { keyword: '', guanliancangku: '' }
this.selectedMaterials = []
this.pagination.page = 1
// area_id /
this.getCangku()
this.getAreaList()
this.getMaterialList()
},
handleClose() {
@ -122,21 +153,22 @@ export default {
async getMaterialList() {
this.loading = true
const filters = []
if (this.searchForm.keyword) {
filters.push({
'key': 'xianwuzimingcheng',
'op': 'like',
'value': this.searchForm.keyword
})
filters.push({ key: 'xianwuzimingcheng', op: 'like', value: this.searchForm.keyword })
}
if (this.searchForm.guanliancangku) {
filters.push({
'key': 'guanliancangku',
'op': 'eq',
'value': this.searchForm.guanliancangku
})
filters.push({ key: 'guanliancangku', op: 'eq', value: this.searchForm.guanliancangku })
}
// area_id flood_materials quyu_id quyu()
// quyu =
if (this.area_id != null && this.area_id !== '') {
//
if (!this.userAreaName) {
await this.getAreaList()
}
if (this.userAreaName) {
filters.push({ key: 'quyu', op: 'eq', value: this.userAreaName })
}
}
try {
@ -146,13 +178,11 @@ export default {
table_name: 'flood_materials',
filter: filters
})
this.materialList = res.data || []
this.pagination.total = res.total || 0
} catch (error) {
Message({
type: 'error',
message: '获取物资列表失败'
})
this.materialList = res?.data ?? []
this.pagination.total = res?.total ?? 0
} catch (e) {
Message({ type: 'error', message: '获取物资列表失败' })
this.materialList = []
} finally {
this.loading = false
}

@ -119,52 +119,45 @@ export default {
}
},
mounted() {
// this.getindex()
this.getindex()
},
methods: {
async getindex(page) {
this.loading = true
if (page == 'page') {
if (page === 'page') {
this.select.pageIndex = 1
}
const filters = [{
'key': 'jingbanren',
'op': 'like',
'value': this.select.jingbanren ? this.select.jingbanren : ''
}]
const filters = []
//
if (this.select.jingbanren) {
filters.push({ key: 'jingbanren', op: 'like', value: this.select.jingbanren })
}
if (this.select.keyword) {
filters.push({ key: 'beizhu', op: 'like', value: this.select.keyword })
}
if (this.select.rukuriqi && this.select.rukuriqi.length === 2) {
filters.push({
'key': 'rukuriqi',
'op': 'gte',
'value': this.select.rukuriqi[0]
})
filters.push({
'key': 'rukuriqi',
'op': 'lte',
'value': this.select.rukuriqi[1]
key: 'rukuriqi',
op: 'range',
value: `${this.select.rukuriqi[0]},${this.select.rukuriqi[1]}`
})
}
//
if (this.select.keyword) {
filters.push({
'key': 'beizhu',
'op': 'like',
'value': this.select.keyword
try {
const res = await index({
page_size: this.select.pageSize,
page: this.select.pageIndex,
table_name: this.customForm.tableName,
filter: filters
})
this.list = res.data || []
this.total = res.total ?? 0
} catch (e) {
this.list = []
this.total = 0
} finally {
this.loading = false
}
const res = await index({
page_size: this.select.pageSize,
page: this.select.pageIndex,
table_name: this.customForm.tableName,
filter: filters
})
this.list = res.data
this.total = res.total
this.loading = false
},
pageChange(e) {
@ -180,12 +173,11 @@ export default {
destroy({
id: row.id,
table_name: this.customForm.tableName
}).then(res => {
Message({
type: 'success',
message: '删除成功'
})
}).then(() => {
Message({ type: 'success', message: '删除成功' })
this.getindex()
}).catch(() => {
Message({ type: 'error', message: '删除失败' })
})
}
}

@ -119,52 +119,45 @@ export default {
}
},
mounted() {
// this.getindex()
this.getindex()
},
methods: {
async getindex(page) {
this.loading = true
if (page == 'page') {
if (page === 'page') {
this.select.pageIndex = 1
}
const filters = [{
'key': 'jingbanren',
'op': 'like',
'value': this.select.jingbanren ? this.select.jingbanren : ''
}]
const filters = []
//
if (this.select.jingbanren) {
filters.push({ key: 'jingbanren', op: 'like', value: this.select.jingbanren })
}
if (this.select.keyword) {
filters.push({ key: 'beizhu', op: 'like', value: this.select.keyword })
}
if (this.select.chukuriqi && this.select.chukuriqi.length === 2) {
filters.push({
'key': 'chukuriqi',
'op': 'gte',
'value': this.select.chukuriqi[0]
})
filters.push({
'key': 'chukuriqi',
'op': 'lte',
'value': this.select.chukuriqi[1]
key: 'chukuriqi',
op: 'range',
value: `${this.select.chukuriqi[0]},${this.select.chukuriqi[1]}`
})
}
//
if (this.select.keyword) {
filters.push({
'key': 'beizhu',
'op': 'like',
'value': this.select.keyword
try {
const res = await index({
page_size: this.select.pageSize,
page: this.select.pageIndex,
table_name: this.customForm.tableName,
filter: filters
})
this.list = res.data || []
this.total = res.total ?? 0
} catch (e) {
this.list = []
this.total = 0
} finally {
this.loading = false
}
const res = await index({
page_size: this.select.pageSize,
page: this.select.pageIndex,
table_name: this.customForm.tableName,
filter: filters
})
this.list = res.data
this.total = res.total
this.loading = false
},
pageChange(e) {
@ -180,12 +173,11 @@ export default {
destroy({
id: row.id,
table_name: this.customForm.tableName
}).then(res => {
Message({
type: 'success',
message: '删除成功'
})
}).then(() => {
Message({ type: 'success', message: '删除成功' })
this.getindex()
}).catch(() => {
Message({ type: 'error', message: '删除失败' })
})
}
}

@ -18,7 +18,7 @@
<div class="xy-table-item-content">
<el-select v-model="form.guanliancangku" style="width: 300px;" placeholder="请选择仓库" @change="changeCk">
<el-option
v-for="item in cangkuList"
v-for="item in filteredCangkuList"
:key="item.id"
:label="item.cangkumingcheng"
:value="item.id"
@ -43,7 +43,17 @@
<span style="color: red;font-weight: 600;padding-right: 4px;" />一级分类
</div>
<div class="xy-table-item-content">
<el-input v-model="form.yijifenlei" placeholder="请填写一级分类" clearable style="width: 300px;" />
<el-cascader
v-model="yijifenleiValue"
ref="yijifenleiCascader"
clearable
popper-class="select_popper"
placeholder="请选择一级分类(必须选到最后一级)"
style="width: 300px;"
:options="fenleiList"
:props="{label:'name',value:'id'}"
@change="changeYijifenlei"
/>
</div>
</div>
</template>
@ -53,7 +63,17 @@
<span style="color: red;font-weight: 600;padding-right: 4px;" />二级分类
</div>
<div class="xy-table-item-content">
<el-input v-model="form.erjifenlei" placeholder="请填写二级分类" clearable style="width: 300px;" />
<el-cascader
v-model="erjifenleiValue"
ref="erjifenleiCascader"
clearable
popper-class="select_popper"
placeholder="请选择二级分类(必须选到最后一级)"
style="width: 300px;"
:options="fenleiList"
:props="{label:'name',value:'id'}"
@change="changeErjifenlei"
/>
</div>
</div>
</template>
@ -63,7 +83,17 @@
<span style="color: red;font-weight: 600;padding-right: 4px;" />所属种类
</div>
<div class="xy-table-item-content">
<el-input v-model="form.fenlei" placeholder="请填写所属种类" clearable style="width: 300px;" />
<el-cascader
v-model="fenleiValue"
ref="fenleiCascader"
clearable
popper-class="select_popper"
placeholder="请选择所属种类(必须选到最后一级)"
style="width: 300px;"
:options="fenleiList"
:props="{label:'name',value:'id'}"
@change="changeFenlei"
/>
</div>
</div>
</template>
@ -73,7 +103,27 @@
<span style="color: red;font-weight: 600;padding-right: 4px;" />区域
</div>
<div class="xy-table-item-content">
<el-input v-model="form.quyu" placeholder="请填写区域" clearable style="width: 300px;" />
<el-input
v-if="area_id"
v-model="form.quyu"
placeholder="区域"
readonly
style="width: 300px;"
/>
<el-select
v-else
v-model="form.quyu"
placeholder="请选择区域"
clearable
style="width: 300px;"
>
<el-option
v-for="item in areaList"
:key="item.id"
:label="item.value"
:value="item.value"
/>
</el-select>
</div>
</div>
</template>
@ -282,6 +332,10 @@ import {
import {
index as getFenleilist
} from '@/api/fenlei.js'
import {
getparameteritem
} from '@/api/system/dictionary.js'
import { mapState } from 'vuex'
export default {
props: {
//
@ -290,6 +344,9 @@ export default {
default: false
}
},
computed: {
...mapState('user', ['area_id'])
},
data() {
return {
isShow: false,
@ -298,8 +355,13 @@ export default {
titleName: '',
tableName: 'flood_materials',
cangkuList: [],
fenleiList: [],
filteredCangkuList: [],
areaList: [],
fenleiList: [],
fenleiName: '',
yijifenleiValue: [],
erjifenleiValue: [],
fenleiValue: [],
form: {
guanliancangku: '',
cangkumingcheng: '',
@ -331,6 +393,26 @@ export default {
guanliancangku: [{
required: true,
message: '请选择仓库'
}],
fenlei: [{
required: true,
message: '请选择所属种类(三级分类)',
trigger: 'change'
}],
quyu: [{
required: true,
message: '区域不能为空',
trigger: 'blur'
}],
xianwuzimingcheng: [{
required: true,
message: '请输入现物资名称',
trigger: 'blur'
}],
shuliang: [{
required: true,
message: '请输入数量',
trigger: 'blur'
}]
}
}
@ -339,53 +421,201 @@ export default {
isShow(newVal) {
if (newVal) {
this.titleName = this.type === 'add' ? `新增物资` : `编辑物资`
//
this.setUserArea()
//
this.filterCangkuList()
//
this.yijifenleiValue = []
this.erjifenleiValue = []
this.fenleiValue = []
if (this.type === 'editor') {
this.getDetail()
}
} else {
this.id = ''
this.type = ''
this.yijifenleiValue = []
this.erjifenleiValue = []
this.fenleiValue = []
this.$refs['dialog'].reset()
}
}
},
created() {
this.getFenlei()
this.getAreaList()
},
methods: {
// children=[]
// children
removeEmptyChildren(node) {
if (Array.isArray(node)) {
return node.map(child => {
if (child.children) {
child.children = this.removeEmptyChildren(child.children)
if (child.children.length === 0) {
delete child.children
}
}
return child
})
}
return []
},
async getFenlei() {
const res = await getFenleilist({
tree: 1,
sort_type: 'ASC',
sort_name: 'sort'
})
this.fenleiList = res
this.fenleiList = this.removeEmptyChildren(res)
},
async getAreaList() {
try {
const res = await getparameteritem('area')
this.areaList = res.detail || []
} catch (error) {
console.error('获取区域列表失败', error)
}
},
setUserArea() {
// area_id
if (this.area_id && this.areaList.length > 0) {
const area = this.areaList.find(item => item.id == this.area_id)
if (area) {
this.form.quyu = area.value
}
}
},
filterCangkuList() {
// area_id
// area_idnullundefined
if (this.area_id != null && this.area_id !== '') {
this.filteredCangkuList = this.cangkuList.filter(item => item.quyu_id == this.area_id)
} else {
// area_id
this.filteredCangkuList = this.cangkuList
}
},
// cascader valueid
getPathNodes(value) {
if (!Array.isArray(value) || value.length === 0) return null
const pathNodes = []
let currentList = this.fenleiList
for (const nodeId of value) {
const node = (currentList || []).find(item => item.id == nodeId)
if (!node) return null
pathNodes.push(node)
currentList = node.children
}
return pathNodes
},
changeFenlei(e) {
console.log('e', e)
this.form.fenlei = e[e.length - 1]
console.log(this.$refs.cascaders.getCheckedNodes())
let data = this.$refs.cascaders.getCheckedNodes() ? this.$refs.cascaders.getCheckedNodes()[0].data : null
if (data) {
this.fenleiName = data.name
// + cascader
handleFenleiSelected(value) {
if (!Array.isArray(value) || value.length === 0) {
this.form.yijifenlei = ''
this.form.erjifenlei = ''
this.form.fenlei = ''
this.yijifenleiValue = []
this.erjifenleiValue = []
this.fenleiValue = []
return
}
const pathNodes = this.getPathNodes(value)
if (!pathNodes || pathNodes.length === 0) {
Message({ type: 'error', message: '分类数据异常,请重新选择' })
this.yijifenleiValue = []
this.erjifenleiValue = []
this.fenleiValue = []
return
}
const lastNode = pathNodes[pathNodes.length - 1]
// removeEmptyChildren children
if (lastNode && lastNode.children && lastNode.children.length > 0) {
Message({ type: 'warning', message: '必须选择到最后一级' })
return
}
console.log(this.form.fenlei)
this.form.yijifenlei = pathNodes[0]?.name || ''
this.form.erjifenlei = pathNodes[1]?.name || ''
this.form.fenlei = lastNode?.name || ''
// cascader
this.yijifenleiValue = value
this.erjifenleiValue = value
this.fenleiValue = value
},
changeYijifenlei(value) {
this.handleFenleiSelected(value)
},
changeErjifenlei(value) {
this.handleFenleiSelected(value)
},
changeFenlei(value) {
this.handleFenleiSelected(value)
},
setCkList(e) {
if (e) {
this.cangkuList = e
//
this.filterCangkuList()
}
},
changeCk(e) {
if (e) {
const selectedWarehouse = this.cangkuList.find(item => e === item.id)
const selectedWarehouse = this.filteredCangkuList.find(item => e === item.id)
if (selectedWarehouse) {
this.form.guanliancangku = selectedWarehouse.id
this.form.cangkumingcheng = selectedWarehouse.cangkumingcheng
// area_id quyu_id
if ((this.area_id == null || this.area_id === '') && selectedWarehouse.quyu_id && this.areaList.length > 0) {
const area = this.areaList.find(item => item.id == selectedWarehouse.quyu_id)
if (area) {
this.form.quyu = area.value
}
}
}
console.log(this.form.guanliancangku)
}
},
// ID
findFenleiPath(list, targetName, path = []) {
for (let i = 0; i < list.length; i++) {
const node = list[i]
const currentPath = [...path, node.id]
if (node.name === targetName) {
return currentPath
}
if (node.children && node.children.length > 0) {
const found = this.findFenleiPath(node.children, targetName, currentPath)
if (found) {
return found
}
}
}
return null
},
//
setCascaderValue() {
// cascader
if (!this.fenleiList || this.fenleiList.length === 0) return
const targetName = this.form.fenlei || this.form.erjifenlei || this.form.yijifenlei
if (!targetName) return
const path = this.findFenleiPath(this.fenleiList, targetName)
if (path && path.length > 0) {
this.yijifenleiValue = path
this.erjifenleiValue = path
this.fenleiValue = path
}
},
async getDetail() {
const res = await show({
id: this.id,
@ -417,8 +647,11 @@ export default {
chubeicengji: res?.chubeicengji,
shifouzhanshi: res?.shifouzhanshi,
is_chart: res?.is_chart
}
// fenleiList
this.$nextTick(() => {
this.setCascaderValue()
})
},
submit() {
console.log('this.form', this.form)
@ -433,6 +666,34 @@ export default {
})
return
}
if (!this.form.fenlei) {
Message({
type: 'warning',
message: '请选择所属种类(三级分类)'
})
return
}
if (!this.form.quyu) {
Message({
type: 'warning',
message: '区域不能为空'
})
return
}
if (!this.form.xianwuzimingcheng) {
Message({
type: 'warning',
message: '请输入现物资名称'
})
return
}
if (!this.form.shuliang) {
Message({
type: 'warning',
message: '请输入数量'
})
return
}
//
this.$emit('material-added', { ...this.form })
@ -442,8 +703,38 @@ export default {
return
}
//
//
if (this.type === 'add') {
//
if (!this.form.fenlei) {
Message({
type: 'warning',
message: '请选择所属种类(三级分类)'
})
return
}
if (!this.form.quyu) {
Message({
type: 'warning',
message: '区域不能为空'
})
return
}
if (!this.form.xianwuzimingcheng) {
Message({
type: 'warning',
message: '请输入现物资名称'
})
return
}
if (!this.form.shuliang) {
Message({
type: 'warning',
message: '请输入数量'
})
return
}
save({
table_name: this.tableName,
...this.form

@ -17,11 +17,13 @@
</Select>
<Button type="primary" @click="getindex('page')"></Button>
<Button
v-if="!area_id"
type="primary"
style="margin-left: 10px;"
@click="$refs['addMater'].isShow = true,$refs['addMater'].type = 'add',$refs['addMater'].setCkList(cangkuList)"
>添加</Button>
<Button
v-if="!area_id"
type="primary"
style="margin-left: 10px;"
@click="$refs['imports'].show()"
@ -58,6 +60,7 @@
<template slot-scope="scope">
<div>
<Button
v-if="canEdit(scope.row)"
type="primary"
size="small"
style="margin-left: 10px;"
@ -96,11 +99,15 @@ import {
import {
index as getFenleilist
} from '@/api/fenlei.js'
import { mapState } from 'vuex'
export default {
components: {
addMater,
imports
},
computed: {
...mapState('user', ['area_id'])
},
data() {
return {
loading: false,
@ -167,12 +174,13 @@ export default {
prop: 'fenlei',
align: 'center'
},
// {
// label: "",
// width: 120,
// prop: 'suozaiquyu',
// align: 'center',
// },
{
label: '所在区域',
width: 120,
prop: 'quyu',
align: 'center',
slot: true
},
{
label: '物资代码',
width: 120,
@ -424,7 +432,49 @@ export default {
this.select.pageIndex = e
this.getindex()
},
//
canEdit(row) {
// area_id
if (!this.area_id || this.area_id === null || this.area_id === '') {
return true
}
// area_id
// 1. quyu_id area_id
if (row.quyu_id && row.quyu_id == this.area_id) {
return true
}
// 2. quyu
if (row.quyu) {
// areaList
const userArea = this.areaList.find(item => item.id == this.area_id)
if (userArea && userArea.value == row.quyu) {
return true
}
}
// 3. quyu_id area_id
if (row.guanliancangku) {
const warehouse = this.cangkuList.find(item => item.id == row.guanliancangku)
if (warehouse && warehouse.quyu_id == this.area_id) {
return true
}
}
return false
},
editorMater(id, type) {
//
const row = this.list.find(item => item.id === id)
if (row && !this.canEdit(row)) {
Message({
type: 'warning',
message: '您只能编辑自己区域的记录'
})
return
}
this.$refs['addMater'].id = id
this.$refs['addMater'].type = type
this.$refs['addMater'].setCkList(this.cangkuList)

@ -7,10 +7,10 @@
<div slot="content" />
<slot>
<div>
<Input
v-model.number="searchFields.keyword"
<Input
v-model.number="searchFields.keyword"
style="width: 200px; margin-right: 10px"
placeholder="关键字搜索"
placeholder="关键字搜索"
/>
<Button type="primary" style="margin-left: 10px" @click="load"></Button>
<Button type="primary" style="margin-left: 10px" @click="edit()"></Button>
@ -23,13 +23,18 @@
<el-table :data="tableData" class="v-table" :height="tableHeight" border style="width: 100%">
<el-table-column type="index" align="center" />
<el-table-column prop="name" label="用户" width="180" />
<el-table-column prop="username" label="用户名" />
<el-table-column prop="username" label="用户名" />
<el-table-column prop="sortnumber" label="排序" />
<el-table-column prop="dept" label="部门">
<template slot-scope="scope">
{{ scope.row.department?scope.row.department.name:'' }}
</template>
</el-table-column>
<el-table-column prop="area" label="区域" width="120">
<template slot-scope="scope">
{{ getAreaName(scope.row.area_id) }}
</template>
</el-table-column>
<el-table-column prop="address" label="角色">
<template slot-scope="scope">
<el-tag v-for="(item,index) in scope.row.roles" size="medium" style="margin-right: 10px;">{{ item.name }}
@ -40,11 +45,11 @@
<template slot-scope="scope">
<el-popover ref="popoverBox" placement="left" width="400" trigger="click">
<div style="margin-bottom: 15px;">选择角色</div>
<el-checkbox
v-for="(role,index) in scope.row.rolelist"
:key="role.id"
<el-checkbox
v-for="(role,index) in scope.row.rolelist"
:key="role.id"
v-model="role.checked"
:label="role.name"
:label="role.name"
>
{{ role.name }}
</el-checkbox>
@ -60,22 +65,22 @@
</el-table>
<div class="pagination">
<el-pagination
:current-page="paginations.page"
<el-pagination
:current-page="paginations.page"
:page-size="paginations.page_size"
background
layout="prev, pager, next"
:total="paginations.total"
@current-change="handleCurrentChange"
background
layout="prev, pager, next"
:total="paginations.total"
@current-change="handleCurrentChange"
/>
</div>
</div>
<el-dialog title="用户编辑" :visible.sync="dialogFormVisible" width="30%">
<el-form ref="form" :model="form" :rules="rules" label-position="right" :label-width="formLabelWidth">
<el-form-item label="排序" prop="sortnumber">
<el-input v-model="form.sortnumber" autocomplete="off" />
</el-form-item>
<el-form-item label="排序" prop="sortnumber">
<el-input v-model="form.sortnumber" autocomplete="off" />
</el-form-item>
<el-form-item label="姓名" prop="name">
<el-input v-model="form.name" autocomplete="off" />
</el-form-item>
@ -91,6 +96,11 @@
<el-option v-for="item in depts" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="区域" prop="area_id">
<el-select v-model="form.area_id" placeholder="请选择区域" clearable>
<el-option v-for="item in areaList" :key="item.id" :label="item.value" :value="item.id" />
</el-select>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="resetForm('form')"> </el-button>
@ -115,25 +125,30 @@ import {
import {
listdept
} from '../../api/system/department.js'
import {
getparameteritem
} from '../../api/system/dictionary.js'
export default {
components: {
LxHeader
},
data() {
data() {
return {
depts: [],
areaList: [],
roleList: [],
checkAll: false,
isIndeterminate: true,
dialogFormVisible: false,
formLabelWidth: '120px',
userNameStatus: true,
form: {
form: {
sortnumber: 0,
name: '',
username: '',
password: '',
department_id: ''
department_id: '',
area_id: ''
},
paginations: {
page: 1,
@ -193,6 +208,11 @@ export default {
}).catch(error => {
})
getparameteritem('area').then(res => {
that.areaList = res.detail || []
}).catch(error => {
console.error('获取区域列表失败', error)
})
},
loadRole(callback) {
list().then(response => {
@ -271,8 +291,8 @@ export default {
if (obj) {
var result = Object.assign(this.form, obj)
this.userNameStatus = false
this.form = result
this.form.rolelist = []
this.form = result
this.form.rolelist = []
this.form.roles = []
} else {
this.userNameStatus = true
@ -329,11 +349,16 @@ export default {
document.body.click()
}).catch(error => {
// reject(error)
})
})
},
getAreaName(areaId) {
if (!areaId) return ''
const area = this.areaList.find(item => item.id === areaId)
return area ? area.value : ''
}
}
}
</script>
<style>
</style>
</style>

@ -52,6 +52,10 @@ module.exports = {
},
//before: require('./mock/mock-server.js'),
proxy: {
// 原来的配置方式
// 注意:由于 request.js 中直接使用 process.env.VUE_APP_BASE_API 作为 baseURL
// 请求会直接发送到 http://wzgl.localhost/,不会经过这个代理
// 如果后端配置了 CORS可以直接使用如果遇到跨域问题需要修改 request.js 或使用下面的代理配置
[process.env.VUE_APP_BASE_API]: {
target: process.env.VUE_APP_BASE_API,
changeOrigin: true, //配置跨域

Loading…
Cancel
Save