You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

531 lines
16 KiB

3 years ago
<template>
2 years ago
<div>
3 years ago
<div ref="lxHeader">
3 years ago
<lx-header icon="md-apps" text="库存管理" style="margin-bottom: 10px; border: 0px; margin-top: 15px">
3 years ago
<slot>
2 years ago
<div style="display: flex;justify-content: flex-start;flex-wrap: wrap;">
<div class="selector-item">
<span class="selector-item__label">物资编码</span>
<Input v-model="select.wzbm" style="width: 120px;margin-right: 10px;" placeholder="物资编码搜索" />
</div>
2 years ago
<div class="selector-item">
<span class="selector-item__label">资产名称</span>
<Input v-model="select.keyword" style="width: 120px;margin-right: 10px;" placeholder="资产名称搜索" />
</div>
<div class="selector-item">
<span class="selector-item__label">入库数量</span>
<Input clearable v-model="select.rmin" style="width: 60px;margin:0 3px" placeholder="" />
<span class="selector-item__label"></span>
<Input clearable v-model="select.rmax" style="width: 60px;margin:0 3px" placeholder="" />
</div>
<div class="selector-item">
<span class="selector-item__label">在库数量</span>
<Input clearable v-model="select.min" style="width: 60px;margin:0 3px" placeholder="" />
<span class="selector-item__label"></span>
<Input clearable v-model="select.max" style="width: 60px;margin:0 3px" placeholder="" />
</div>
<Button type="primary" style="margin-left: 10px;" @click="getindex"></Button>
<Button type="primary" style="margin-left: 10px;" @click="toprint"></Button>
1 year ago
<!-- <Button type="primary" style="margin-left: 10px;"
@click="exportExcel(new Date().getTime().toString())">导出</Button> -->
3 years ago
3 years ago
</div>
</slot>
</lx-header>
</div>
2 years ago
<xy-table :list="list" v-loading="loading" :total="total" @selection-change="selectionChange"
@pageSizeChange="e => select.pageSize = e" @pageIndexChange="pageChange" :table-item="table" :auths='[]'>
1 year ago
<template v-slot:btns>
2 years ago
<!-- <div></div> -->
1 year ago
<el-table-column v-if="isPandian==='pandian' && (isCkName=='仓库管理员'||roleName=='系统管理员')" fixed="right" align="center" label="操作" width="120" header-align="center">
2 years ago
<template slot-scope="scope">
1 year ago
<Button type="primary" size="small" @click="editorIn(scope.row.id,'editor')"></Button>
2 years ago
<!-- <Poptip transfer confirm title="确认要删除吗?" @on-ok="deleteIn(scope.row)">
3 years ago
<Button type="primary" style="margin-left: 10px;" size="small" ghost>删除</Button>
2 years ago
</Poptip> -->
3 years ago
</template>
1 year ago
</el-table-column>
<div v-else></div>
3 years ago
</template>
</xy-table>
2 years ago
<addInventorys ref="addInventorys" @refresh="getindex"></addInventorys>
<div class="code" v-if="showcode" @click="closeCode">
<div id="qrCode" ref="qrCodeDiv"></div>
</div>
3 years ago
<imports :table-name="customForm.tableName" :form-info="form" ref="imports" @refresh="getindex"></imports>
</div>
</template>
<script>
import {
index,
destroy
2 years ago
} from "@/api/system/baseForm.js"
import {
getInfo
} from "@/api/user.js"
import addInventorys from "./components/addInventorys.vue"
3 years ago
import QRCode from 'qrcodejs2';
3 years ago
import {
Message
} from 'element-ui'
2 years ago
import imports from "@/views/component/imports.vue"
import {
index as fieldIndex
} from "@/api/system/customFormField";
import {
getparameter
} from "@/api/system/dictionary";
import * as XLSX from "xlsx";
import {
saveAs
} from "file-saver";
3 years ago
import Cookies from 'js-cookie'
3 years ago
export default {
components: {
2 years ago
imports,
addInventorys
3 years ago
},
data() {
2 years ago
return {
loading: false,
userName:'',
authName:'',
roleName:'',
1 year ago
isCkName:'',
isPandian:'',
3 years ago
select: {
pageSize: 10,
pageIndex: 1,
2 years ago
keyword: "",
wzbm:'',
2 years ago
is_export: 0,
min: '',
max: '',
rmin: '',
rmax: ''
},
showcode: false,
customForm: {
customFormId: "",
tableName: "inventorys"
},
form: [],
3 years ago
total: 0,
list: [],
2 years ago
table: [{
type: 'selection'
2 years ago
},
{
2 years ago
label: '序号',
type: 'index',
fixed: 'left',
width: 80,
},
{
label: "物资编码",
width: 180,
prop: 'wuzibianma',
align: 'center',
formatter: (cell, data, value, index) => {
if(cell.wuzibianma_material_infos_wuzibianma_relation?.wuzibianma){
return cell.wuzibianma_material_infos_wuzibianma_relation.wuzibianma
}else{
return value
}
}
},
{
label: "资产名称",
prop: 'zichanmingcheng',
align: 'center',
formatter: (cell, data, value, index) => {
if(cell.wuzibianma_material_infos_wuzibianma_relation?.zichanmingcheng){
return cell.wuzibianma_material_infos_wuzibianma_relation.zichanmingcheng
}else{
return value
}
}
},
{
label: "规格型号",
prop: 'guigexinghao',
align: 'center',
width: 180,
formatter: (cell, data, value, index) => {
if(cell.wuzibianma_material_infos_wuzibianma_relation?.guigexinghao){
return cell.wuzibianma_material_infos_wuzibianma_relation.guigexinghao
}else{
return value
}
}
},
3 years ago
{
3 years ago
label: "物资类型",
3 years ago
width: 120,
3 years ago
prop: 'wuzileixing',
2 years ago
align: 'center',
formatter: (cell, data, value, index) => {
if(cell.wuzibianma_material_infos_wuzibianma_relation?.wuzileixing){
return cell.wuzibianma_material_infos_wuzibianma_relation.wuzileixing
}else{
return value
}
}
3 years ago
},
{
3 years ago
label: "计量单位",
width: 120,
prop: 'jiliangdanwei',
2 years ago
align: 'center',
formatter: (cell, data, value, index) => {
if(cell.wuzibianma_material_infos_wuzibianma_relation?.jiliangdanwei){
return cell.wuzibianma_material_infos_wuzibianma_relation.jiliangdanwei
}else{
return value
}
}
3 years ago
},
{
3 years ago
label: "入库数量",
width: 120,
prop: 'rukushuliang'
2 years ago
},
{
label: "在库数量",
width: 120,
prop: 'zaikushuliang'
},
{
label: "入库批次",
width: 120,
prop: 'rukupici'
2 years ago
},
{
label: "生产日期",
width: 120,
prop: 'shengchanriqi'
2 years ago
},
{
label: "固定资产编号",
width: 180,
prop: 'gudingzichanbianhao',
align: 'center',
formatter: (cell, data, value, index) => {
if(cell.wuzibianma_material_infos_wuzibianma_relation?.gudingzichanbianhao){
return cell.wuzibianma_material_infos_wuzibianma_relation.gudingzichanbianhao
}else{
return value
}
}
},
{
label: "所在仓库",
width: 180,
prop: 'suozaicangku',
formatter: (cell, data, value, index) => {
if(cell.wuzibianma_material_infos_wuzibianma_relation?.suozaicangku){
return cell.wuzibianma_material_infos_wuzibianma_relation.suozaicangku
}else{
return value
}
}
},
{
label: "所在货架",
width: 180,
prop: 'suozaihuojia',
formatter: (cell, data, value, index) => {
if(cell.wuzibianma_material_infos_wuzibianma_relation?.suozaihuojia){
return cell.wuzibianma_material_infos_wuzibianma_relation.suozaihuojia
}else{
return value
}
}
},
// {
// label: "二维码",
// width: 180,
// prop: 'erweima',
// customFn: (row) => {
// return (<Button type='primary' size='small'
// on=
// {
// {
// ["click"]: (e) => (this.showCode(e, row))
// }
// }
// >生成二维码</Button>)
// }
3 years ago
// },
2 years ago
],
printObj: [],
printArr: []
3 years ago
}
2 years ago
},
mounted() {
1 year ago
if (this.$route.path) {
let path = this.$route.path.split("_")
if(path[1]){
this.isPandian = 'pandian'
}
}
2 years ago
this.getField()
this.getindex()
this.getUserName()
1 year ago
3 years ago
},
3 years ago
methods: {
2 years ago
async getUserName(){
getInfo().then(res => {
console.log("res",res)
this.userName = res.username
this.authName = res.name
for(var k of res.role){
if(k.name=='系统管理员'){
this.roleName = k.name
3 years ago
}
2 years ago
if(k.name=='仓库管理员'){
this.isCkName = '仓库管理员'
}
}
3 years ago
2 years ago
}).catch(error => {})
},
selectionChange(e) {
console.log(e)
let _arrs = []
if (e.length > 0) {
for (var m of e) {
_arrs.push(m.id)
}
console.log(_arrs)
// this.printObj = e
this.printArr = _arrs.join(",")
}
},
toprint() {
if (this.printArr.length < 1) {
Message({
type: 'warning',
message: '请先选择'
})
return
}
// let _obj = JSON.parse(JSON.stringify(this.printObj))
// let _objs = []
// for(var m of this.printObj){
// _objs.push({
// 'wuzibianma':encodeURI(encodeURI(m['wuzibianma'])),
// 'zichanmingcheng':encodeURI(encodeURI(m['zichanmingcheng'])),
// 'wuzileixing':encodeURI(encodeURI(m['wuzileixing']))
// })
// }
// Cookies.remove('objs')
// Cookies.set('objs',JSON.stringify(_objs))
window.open('/admin/print.html?ids=' + this.printArr, '_blank')
},
async exportExcel(sheetName) {
const res = await index(Object.assign(this.select, {
page: 1,
page_size: 9999,
table_name: 'inventorys'
}))
if (res.data) {
let headers = this.form.map(i => {
return {
key: i.field,
title: i.name
}
})
const data = res.data.map(row => headers.map(header => row[header.key]));
data.unshift(headers.map(header => header.title));
const wb = XLSX.utils.book_new();
const ws = XLSX.utils.aoa_to_sheet(data);
XLSX.utils.book_append_sheet(wb, ws, sheetName);
const wbout = XLSX.write(wb, {
bookType: 'xlsx',
bookSST: true,
type: 'array'
});
saveAs(new Blob([wbout], {
type: 'application/octet-stream'
}), `${sheetName}.xlsx`);
}
3 years ago
},
2 years ago
showCode(e, row) {
console.log(e, row)
this.showcode = true
this.$nextTick(function() {
new QRCode(this.$refs.qrCodeDiv, {
text: row.wuzibianma + '-' + row.id,
width: 200,
height: 200,
colorDark: "#333333", //二维码颜色
colorLight: "#ffffff", //二维码背景色
correctLevel: QRCode.CorrectLevel.L //容错率L/M/H
})
})
},
closeCode() {
this.$refs.qrCodeDiv.innerHTML = ""
this.showcode = false
2 years ago
},
search(){
this.select.pageIndex = 1
this.getindex()
2 years ago
},
async getindex() {
this.loading = true
2 years ago
let min = this.select.min?this.select.min:0
2 years ago
let max = this.select.max?this.select.max:99999
2 years ago
let rmin = this.select.rmin?this.select.rmin:0
2 years ago
let rmax = this.select.rmax?this.select.rmax:99999
3 years ago
const res = await index({
3 years ago
page_size: this.select.pageSize,
3 years ago
page: this.select.pageIndex,
2 years ago
table_name: 'inventorys',
// is_export:this.select.is_export,
filter: [{
2 years ago
"key": "wuzibianma",
"op": "like",
"value": this.select.wzbm,
},{
2 years ago
"key": "zichanmingcheng",
"op": "like",
"value": this.select.keyword,
},
{
"key": "rukushuliang",
"op": "range",
"value": rmin + "," + rmax,
},
{
"key": "zaikushuliang",
"op": "range",
"value": min + "," + max,
},
],
3 years ago
})
this.list = res.data
2 years ago
this.total = res.total
2 years ago
this.loading = false
2 years ago
},
3 years ago
pageChange(e) {
2 years ago
this.select.pageIndex = e
3 years ago
this.getindex()
3 years ago
},
2 years ago
editorIn(id, type) {
this.$refs['addInventorys'].id = id
this.$refs['addInventorys'].isShow = true
this.$refs['addInventorys'].type = type
},
deleteIn(row) {
console.log(row.id)
3 years ago
// return
destroy({
2 years ago
id: row.id,
table_name: this.customForm.tableName
3 years ago
}).then(res => {
Message({
type: 'success',
message: '删除成功'
})
this.getindex()
})
},
2 years ago
async getField() {
if (this.$route.meta.params?.custom_form) {
let decode = decodeURIComponent(this.$route.meta.params?.custom_form)
try {
let custom_form = JSON.parse(decode)
this.customForm.customFormId = custom_form.custom_form_id
this.customForm.tableName = custom_form.table_name
console.log("123", this.customForm)
// this.select.table_name = custom_form.table_name
} catch (err) {
console.warn(err)
}
}
const res = await fieldIndex({
page: 1,
page_size: 999,
custom_form_id: this.customForm.customFormId,
sort_name: 'sort',
sort_type: 'asc',
})
if (res.data && res.data instanceof Array) {
res.data.forEach(i => {
if (i.field) {
if (
(i.edit_input === "checkbox" || i.edit_input === "radio" || i.edit_input === "select") &&
i.parameter_id
) {
getparameter({
id: i.parameter_id
}).then((res) => {
i._paramters = res.detail ?? [];
});
}
if (
(i.edit_input === "checkbox" || i.edit_input === "radio" || i.edit_input === "select") &&
i.link_table_name
) {
index({
page: 1,
page_size: 999,
table_name: i.link_table_name,
}).then((res) => {
i._paramters = res.data ?? [];
});
}
}
})
}
2 years ago
// this.form = res.data
this.form = res.data
?.filter((i) => i.list_show)
.map((i) => {
return i
})
console.log(this.form)
2 years ago
},
3 years ago
}
}
</script>
2 years ago
<style scoped lang="scss">
.code {
position: absolute;
left: 0;
top: 0;
background: rgba(0, 0, 0, 0.5);
width: 100%;
height: 100%;
z-index: 9999
}
3 years ago
2 years ago
#qrCode {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
3 years ago
</style>