This commit is contained in:
parent
4da4816833
commit
86503555ee
|
|
@ -146,7 +146,8 @@
|
|||
<el-form
|
||||
ref="dialogForm"
|
||||
:model="dialogForm"
|
||||
label-width="110px"
|
||||
:rules="dialogRules"
|
||||
label-width="115px"
|
||||
size="small"
|
||||
inline
|
||||
@submit.native.prevent
|
||||
|
|
@ -191,7 +192,7 @@
|
|||
</el-select>
|
||||
</el-form-item>
|
||||
<!-- 厂家 -->
|
||||
<el-form-item label="生产厂家">
|
||||
<el-form-item label="生产厂家" prop="supplierId">
|
||||
<el-select v-model="dialogForm.supplierId" placeholder="请选择厂家" clearable style="width: 240px">
|
||||
<el-option
|
||||
v-for="item in manufacturerSelect"
|
||||
|
|
@ -202,7 +203,7 @@
|
|||
</el-select>
|
||||
</el-form-item>
|
||||
<!-- 出厂日期 -->
|
||||
<el-form-item label="出厂日期">
|
||||
<el-form-item label="出厂日期" prop="productionDate">
|
||||
<el-date-picker
|
||||
v-model="dialogForm.productionDate"
|
||||
type="date"
|
||||
|
|
@ -212,17 +213,17 @@
|
|||
style="width: 240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="本次检验时间">-->
|
||||
<!-- <el-date-picker-->
|
||||
<!-- v-model="dialogForm.lastCheckDate"-->
|
||||
<!-- type="date"-->
|
||||
<!-- clearable-->
|
||||
<!-- placeholder="选择本次检验时间"-->
|
||||
<!-- value-format="yyyy-MM-dd"-->
|
||||
<!-- style="width: 240px"-->
|
||||
<!-- />-->
|
||||
<!-- </el-form-item>-->
|
||||
<el-form-item label="资产原值(万元)">
|
||||
<!-- <el-form-item label="本次检验时间">
|
||||
<el-date-picker
|
||||
v-model="dialogForm.lastCheckDate"
|
||||
type="date"
|
||||
clearable
|
||||
placeholder="选择本次检验时间"
|
||||
value-format="yyyy-MM-dd"
|
||||
style="width: 240px"
|
||||
/>
|
||||
</el-form-item> -->
|
||||
<el-form-item label="资产原值(万元)" prop="originCost">
|
||||
<el-input-number
|
||||
v-model="dialogForm.originCost"
|
||||
:min="0"
|
||||
|
|
@ -232,7 +233,7 @@
|
|||
style="width: 240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="原始编码">
|
||||
<el-form-item label="原始编码" prop="identifyCode">
|
||||
<el-input v-model="dialogForm.identifyCode" maxlength="999" style="width: 240px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="下次检验时间">
|
||||
|
|
@ -441,27 +442,27 @@ export default {
|
|||
{ label: '计量单位', prop: 'unitName' },
|
||||
{ label: '工具编码', prop: 'toolCode' },
|
||||
{
|
||||
label: "工具状态",
|
||||
prop: "status",
|
||||
label: '工具状态',
|
||||
prop: 'status',
|
||||
width: 120,
|
||||
render: (h, { row }) => {
|
||||
const statusOptions = {
|
||||
0: { text: "在库", type: "success" },
|
||||
1: { text: "在用", type: "info" },
|
||||
2: { text: "在修", type: "warning" },
|
||||
3: { text: "已报废", type: "danger" },
|
||||
};
|
||||
0: { text: '在库', type: 'success' },
|
||||
1: { text: '在用', type: 'info' },
|
||||
2: { text: '在修', type: 'warning' },
|
||||
3: { text: '已报废', type: 'danger' },
|
||||
}
|
||||
const option = statusOptions[row.status]
|
||||
return h(
|
||||
"el-tag",
|
||||
'el-tag',
|
||||
{
|
||||
props: {
|
||||
type: option.type,
|
||||
size: "mini",
|
||||
size: 'mini',
|
||||
},
|
||||
},
|
||||
option.text
|
||||
);
|
||||
option.text,
|
||||
)
|
||||
},
|
||||
},
|
||||
{ label: '下次检验时间', prop: 'nextCheckDate' },
|
||||
|
|
@ -495,6 +496,15 @@ export default {
|
|||
inspectionList: '',
|
||||
purchaseInvoicesList: '',
|
||||
},
|
||||
dialogRules: {
|
||||
supplierId: [{ required: true, message: '请选择生产厂家', trigger: 'blur' }],
|
||||
productionDate: [{ required: true, message: '请选择出厂日期', trigger: 'change' }],
|
||||
originCost: [{ required: true, message: '请输入资产原值', trigger: 'blur' }],
|
||||
identifyCode: [{ required: true, message: '请输入原始编码', trigger: 'blur' }],
|
||||
certificateList: [{ required: true, message: '请上传合格证', trigger: 'change' }],
|
||||
inspectionList: [{ required: true, message: '请上传检测证书', trigger: 'change' }],
|
||||
purchaseInvoicesList: [{ required: true, message: '请上传采购发票', trigger: 'change' }],
|
||||
},
|
||||
manufacturerSelect: [],
|
||||
// 上传相关配置(从FileUpload组件迁移)
|
||||
uploadFileUrl: process.env.VUE_APP_BASE_API + '/file/upload', // 上传文件服务器地址
|
||||
|
|
@ -778,6 +788,11 @@ export default {
|
|||
},
|
||||
async submit() {
|
||||
console.log('🚀 ~ methods.submit:', this.dialogForm)
|
||||
// 校验表单
|
||||
const valid = await this.$refs.dialogForm.validate()
|
||||
if (!valid) {
|
||||
return
|
||||
}
|
||||
this.isLoading = true
|
||||
try {
|
||||
let certificates = [] // 合格证
|
||||
|
|
@ -938,4 +953,7 @@ export default {
|
|||
padding: 20px;
|
||||
}
|
||||
}
|
||||
::v-deep .el-input-number.is-without-controls .el-input__inner {
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
size="small"
|
||||
inline
|
||||
@submit.native.prevent
|
||||
style="height: 32px;"
|
||||
style="height: 32px"
|
||||
>
|
||||
<el-form-item label="规格型号">
|
||||
<el-cascader
|
||||
|
|
@ -24,14 +24,21 @@
|
|||
</el-form-item>
|
||||
<!-- 厂家 -->
|
||||
<el-form-item label="生产厂家" prop="supplierId">
|
||||
<el-select v-model="dialogForm.supplierId" placeholder="请选择厂家" clearable style="width: 240px">
|
||||
<el-option
|
||||
v-for="item in manufacturerSelect"
|
||||
:key="item.id"
|
||||
:label="item.label"
|
||||
:value="item.id"
|
||||
></el-option>
|
||||
</el-select>
|
||||
<div>
|
||||
<i
|
||||
class="el-icon-circle-plus-outline"
|
||||
style="color: #13ce66; margin-right: 5px; cursor: pointer"
|
||||
@click="openAddress"
|
||||
/>
|
||||
<el-select v-model="dialogForm.supplierId" placeholder="请选择厂家" clearable style="width: 240px">
|
||||
<el-option
|
||||
v-for="item in manufacturerSelect"
|
||||
:key="item.id"
|
||||
:label="item.label"
|
||||
:value="item.id"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<!-- 出厂日期 -->
|
||||
<el-form-item label="出厂日期" prop="productionDate">
|
||||
|
|
@ -81,8 +88,19 @@
|
|||
align="center"
|
||||
>
|
||||
<!-- 插槽 -->
|
||||
<template v-slot="{ row }" v-if="column.prop == 'supplierId'">
|
||||
<el-select v-model="row.supplierId" placeholder="请选择厂家" style="width: 150px">
|
||||
<template #header>
|
||||
<span>
|
||||
<span v-if="column.required" style="color: red">*</span>
|
||||
{{ column.label }}
|
||||
</span>
|
||||
</template>
|
||||
<template v-slot="{ row }">
|
||||
<el-select
|
||||
v-if="column.prop == 'supplierId'"
|
||||
v-model="row.supplierId"
|
||||
placeholder="请选择厂家"
|
||||
style="width: 150px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in manufacturerSelect"
|
||||
:key="item.id"
|
||||
|
|
@ -90,9 +108,8 @@
|
|||
:value="item.id"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</template>
|
||||
<template v-slot="{ row }" v-else-if="column.prop == 'productionDate'">
|
||||
<el-date-picker
|
||||
v-else-if="column.prop == 'productionDate'"
|
||||
v-model="row.productionDate"
|
||||
type="date"
|
||||
clearable
|
||||
|
|
@ -100,14 +117,50 @@
|
|||
value-format="yyyy-MM-dd"
|
||||
style="width: 150px"
|
||||
/>
|
||||
</template>
|
||||
<!-- 插槽 -->
|
||||
<template v-slot="{ row }" v-else-if="column.prop == 'toolPrice'">
|
||||
<el-input-number v-model="row.toolPrice" :min="0" :max="99999999" :controls="false" style="width: 120px" />
|
||||
</template>
|
||||
<!-- 插槽 -->
|
||||
<template v-slot="{ row }" v-else-if="column.prop == 'identifyCode'">
|
||||
<el-input v-model="row.identifyCode" maxlength="999" style="width: 120px" />
|
||||
<el-input
|
||||
v-else-if="column.prop == 'toolPrice'"
|
||||
v-model="row.toolPrice"
|
||||
placeholder="请输入"
|
||||
maxlength="9999"
|
||||
@input="handlePriceInput(row)"
|
||||
style="width: 120px"
|
||||
/>
|
||||
<el-input
|
||||
v-else-if="column.prop == 'identifyCode'"
|
||||
v-model="row.identifyCode"
|
||||
placeholder="请输入"
|
||||
maxlength="999"
|
||||
style="width: 120px"
|
||||
/>
|
||||
<span v-else-if="column.prop == 'certificates'">
|
||||
<span style="color: #00a288; cursor: pointer" @click="handleFileUpload(row, 2)">上传</span>
|
||||
<span
|
||||
v-if="row.certificates && row.certificates.length > 0"
|
||||
style="color: #00a288; cursor: pointer; margin-left: 10px"
|
||||
@click="handleView(row, 2)"
|
||||
>查看</span
|
||||
>
|
||||
</span>
|
||||
<span v-else-if="column.prop == 'inspectionReports'">
|
||||
<span style="color: #00a288; cursor: pointer" @click="handleFileUpload(row, 3)">上传</span>
|
||||
<span
|
||||
v-if="row.inspectionReports && row.inspectionReports.length > 0"
|
||||
style="color: #00a288; cursor: pointer; margin-left: 10px"
|
||||
@click="handleView(row, 3)"
|
||||
>查看</span
|
||||
>
|
||||
</span>
|
||||
<span v-else-if="column.prop == 'purchaseInvoices'">
|
||||
<span style="color: #00a288; cursor: pointer" @click="handleFileUpload(row, 4)">上传</span>
|
||||
<span
|
||||
v-if="row.purchaseInvoices && row.purchaseInvoices.length > 0"
|
||||
style="color: #00a288; cursor: pointer; margin-left: 10px"
|
||||
@click="handleView(row, 4)"
|
||||
>查看</span
|
||||
>
|
||||
</span>
|
||||
<!-- 其他列默认显示文本 -->
|
||||
<span v-else>{{ row[column.prop] }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center">
|
||||
|
|
@ -120,14 +173,120 @@
|
|||
</el-table>
|
||||
</el-card>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 上传 -->
|
||||
<el-dialog :title="uploadTitle" :visible.sync="uploadVisible" width="40%">
|
||||
<FileUpload
|
||||
v-model="fileList"
|
||||
:value="fileList"
|
||||
:limit="3"
|
||||
:fileSize="10"
|
||||
:fileType="['jpg', 'png', 'pdf']"
|
||||
@input="handleFileList"
|
||||
/>
|
||||
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="uploadVisible = false">关 闭</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
<!-- 查看 -->
|
||||
<el-dialog :title="viewTitle" :visible.sync="viewVisible" width="40%">
|
||||
<el-table :data="viewList" fit highlight-current-row style="width: 100%" height="546">
|
||||
<el-table-column type="index" width="55" label="序号" align="center" />
|
||||
<el-table-column label="附件名称" prop="fileName" align="center">
|
||||
<!-- 插槽 -->
|
||||
<template v-slot="{ row }">
|
||||
<span style="color: #00a288; cursor: pointer" @click="handleFile(row)">{{ row.fileName }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="viewVisible = false">关 闭</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
<!-- 地址 -->
|
||||
<el-dialog title="新增" v-if="showHouse" :visible.sync="showHouse" width="55%" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="135px">
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="统一社会信用代码" prop="supplierCode">
|
||||
<el-input v-model="form.supplierCode" placeholder="请输入统一社会信用代码" maxlength="64" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="厂家名称" prop="supplierName">
|
||||
<el-input v-model="form.supplierName" placeholder="请输入厂家名称" maxlength="128" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="联系人" prop="contactPerson">
|
||||
<el-input v-model="form.contactPerson" placeholder="请输入联系人" maxlength="64" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="联系电话" prop="contactPhone">
|
||||
<el-input v-model="form.contactPhone" placeholder="请输入联系电话" maxlength="11" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="厂家地址" prop="address">
|
||||
<el-input v-model="form.address" placeholder="请输入厂家地址" maxlength="255" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="资质/执照编号" prop="qualification">
|
||||
<el-input v-model="form.qualification" placeholder="请输入资质信息或执照编号" maxlength="255" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select v-model="form.status" placeholder="请选择状态" style="width: 100%">
|
||||
<el-option label="启用" :value="1" />
|
||||
<el-option label="停用" :value="0" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12">
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input
|
||||
type="textarea"
|
||||
:rows="6"
|
||||
placeholder="请输入备注"
|
||||
v-model="form.remark"
|
||||
maxlength="255"
|
||||
show-word-limit
|
||||
>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="showHouse = false">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getTreeSelectApi, addApplyCodeApi, addToolApi } from '@/api/toolsManage'
|
||||
import { getManufacturerSelectApi } from '@/api/EquipmentLedger'
|
||||
import { addFacturer } from '@/api/ma/supplier'
|
||||
import FileUpload from '@/components/FileImageUpload'
|
||||
|
||||
export default {
|
||||
components: { FileUpload },
|
||||
data() {
|
||||
return {
|
||||
isLoading: false,
|
||||
|
|
@ -152,16 +311,42 @@ export default {
|
|||
{ label: '工具名称', prop: 'parentTypeName' },
|
||||
{ label: '规格型号', prop: 'typeName' },
|
||||
{ label: '计量单位', prop: 'unitName' },
|
||||
{ label: '生产厂家', prop: 'supplierId', width: 180 },
|
||||
{ label: '出厂日期', prop: 'productionDate', width: 180 },
|
||||
{ label: '资产原值', prop: 'toolPrice', width: 150 },
|
||||
{ label: '原始编码', prop: 'identifyCode', width: 150 },
|
||||
{ label: '生产厂家', prop: 'supplierId', width: 180, required: true },
|
||||
{ label: '出厂日期', prop: 'productionDate', width: 180, required: true },
|
||||
{ label: '资产原值(万元)', prop: 'toolPrice', width: 150, required: true },
|
||||
{ label: '原始编码', prop: 'identifyCode', width: 150, required: true },
|
||||
{ label: '合格证', prop: 'certificates', width: 100, required: true },
|
||||
{ label: '检测证书', prop: 'inspectionReports', width: 100, required: true },
|
||||
{ label: '发票', prop: 'purchaseInvoices', width: 100, required: true },
|
||||
],
|
||||
dialogList: [],
|
||||
options: [],
|
||||
activeLabels: [],
|
||||
lastNode: null,
|
||||
manufacturerSelect: [],
|
||||
certificates: [], // 合格证
|
||||
inspectionReports: [], // 检测证书
|
||||
purchaseInvoices: [], // 采购发票
|
||||
uploadType: '',
|
||||
currentRow: null,
|
||||
uploadTitle: '',
|
||||
uploadVisible: false,
|
||||
fileList: [],
|
||||
viewVisible: false,
|
||||
viewTitle: '',
|
||||
viewList: [],
|
||||
showHouse: false,
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
supplierCode: [{ required: true, message: '统一社会信用代码不能为空', trigger: 'blur' }],
|
||||
supplierName: [{ required: true, message: '厂家名称不能为空', trigger: 'blur' }],
|
||||
contactPhone: [
|
||||
{ required: false, message: '请输入联系电话', trigger: 'blur' },
|
||||
{ pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: '请输入正确的手机号码', trigger: 'blur' },
|
||||
],
|
||||
status: [{ required: true, message: '请选择状态', trigger: 'change' }],
|
||||
},
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
|
@ -244,6 +429,9 @@ export default {
|
|||
productionDate: this.dialogForm.productionDate,
|
||||
toolPrice: null,
|
||||
identifyCode: null,
|
||||
certificates: [], // 合格证
|
||||
inspectionReports: [], // 检测证书
|
||||
purchaseInvoices: [], // 采购发票
|
||||
})
|
||||
}
|
||||
},
|
||||
|
|
@ -264,6 +452,38 @@ export default {
|
|||
// 提交
|
||||
async submit() {
|
||||
try {
|
||||
// 循环this.dialogList 校验 厂家 出厂日期 资产原值 原始编码 合格证 检测证书 发票 是否填写
|
||||
for (let i = 0; i < this.dialogList.length; i++) {
|
||||
const item = this.dialogList[i]
|
||||
if (!item.supplierId) {
|
||||
this.$message.error(`第${i + 1}行厂家不能为空`)
|
||||
return
|
||||
}
|
||||
if (!item.productionDate) {
|
||||
this.$message.error(`第${i + 1}行出厂日期不能为空`)
|
||||
return
|
||||
}
|
||||
if (!item.toolPrice) {
|
||||
this.$message.error(`第${i + 1}行资产原值不能为空`)
|
||||
return
|
||||
}
|
||||
if (!item.identifyCode) {
|
||||
this.$message.error(`第${i + 1}行原始编码不能为空`)
|
||||
return
|
||||
}
|
||||
if (item.certificates.length == 0) {
|
||||
this.$message.error(`第${i + 1}行合格证不能为空`)
|
||||
return
|
||||
}
|
||||
if (item.inspectionReports.length == 0) {
|
||||
this.$message.error(`第${i + 1}行检测证书不能为空`)
|
||||
return
|
||||
}
|
||||
if (item.purchaseInvoices.length == 0) {
|
||||
this.$message.error(`第${i + 1}行采购发票不能为空`)
|
||||
return
|
||||
}
|
||||
}
|
||||
this.isLoading = true
|
||||
if (!this.dialogForm.applyId) {
|
||||
const res = await addApplyCodeApi()
|
||||
|
|
@ -284,6 +504,102 @@ export default {
|
|||
this.isLoading = false
|
||||
}
|
||||
},
|
||||
openAddress() {
|
||||
this.showHouse = true
|
||||
},
|
||||
submitForm() {
|
||||
this.$refs['form'].validate(async (valid) => {
|
||||
if (valid) {
|
||||
addFacturer(this.form).then((response) => {
|
||||
this.$modal.msgSuccess('新增成功')
|
||||
this.showHouse = false
|
||||
this.getManufacturerSelect()
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
handlePriceInput(row) {
|
||||
let val = String(row.toolPrice ?? '')
|
||||
|
||||
// 1️⃣ 只保留数字和 .
|
||||
val = val.replace(/[^\d.]/g, '')
|
||||
|
||||
// 2️⃣ 只保留第一个小数点
|
||||
const dotIndex = val.indexOf('.')
|
||||
if (dotIndex !== -1) {
|
||||
val = val.slice(0, dotIndex + 1) + val.slice(dotIndex + 1).replace(/\./g, '')
|
||||
}
|
||||
row.toolPrice = val
|
||||
},
|
||||
handleFile(row) {
|
||||
// 打开文件预览
|
||||
window.open(row.fileUrl, '_blank')
|
||||
},
|
||||
// 查看
|
||||
handleView(row, type) {
|
||||
if (type == 2) {
|
||||
this.viewTitle = '合格证'
|
||||
this.viewList = row.certificates || []
|
||||
} else if (type == 3) {
|
||||
this.viewTitle = '检测证书'
|
||||
this.viewList = row.inspectionReports || []
|
||||
} else if (type == 4) {
|
||||
this.viewTitle = '采购发票'
|
||||
this.viewList = row.purchaseInvoices || []
|
||||
}
|
||||
this.viewVisible = true
|
||||
},
|
||||
// 上传
|
||||
handleFileUpload(row, type) {
|
||||
this.uploadType = type
|
||||
this.currentRow = row
|
||||
if (type == 2) {
|
||||
this.uploadTitle = '合格证'
|
||||
this.fileList = row.fileList2
|
||||
} else if (type == 3) {
|
||||
this.uploadTitle = '定期检验报告'
|
||||
this.fileList = row.fileList3
|
||||
} else if (type == 4) {
|
||||
this.uploadTitle = '采购发票'
|
||||
this.fileList = row.fileList4
|
||||
}
|
||||
this.uploadVisible = true
|
||||
},
|
||||
handleFileList(file) {
|
||||
console.log('🚀 ~ file:', file)
|
||||
if (this.uploadType == 2) {
|
||||
this.currentRow.fileList2 = file
|
||||
if (!file) {
|
||||
this.currentRow.certificates = []
|
||||
return
|
||||
}
|
||||
this.currentRow.certificates = this.formatFileList(file)
|
||||
} else if (this.uploadType == 3) {
|
||||
this.currentRow.fileList3 = file
|
||||
if (!file) {
|
||||
this.currentRow.inspectionReports = []
|
||||
return
|
||||
}
|
||||
this.currentRow.inspectionReports = this.formatFileList(file)
|
||||
} else if (this.uploadType == 4) {
|
||||
this.currentRow.fileList4 = file
|
||||
if (!file) {
|
||||
this.currentRow.purchaseInvoices = []
|
||||
return
|
||||
}
|
||||
this.currentRow.purchaseInvoices = this.formatFileList(file)
|
||||
}
|
||||
},
|
||||
formatFileList(file) {
|
||||
const arr = file.split(',')
|
||||
return arr.map((item) => {
|
||||
const parts = item.split('/')
|
||||
return {
|
||||
fileName: parts[parts.length - 1],
|
||||
fileUrl: item,
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,15 @@
|
|||
<div>
|
||||
<el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="70%" :close-on-click-modal="false">
|
||||
<el-card style="margin-bottom: 20px">
|
||||
<el-form v-if="dialogVisible" ref="dialogForm" :model="dialogForm" size="small" inline @submit.native.prevent style="height: 32px">
|
||||
<el-form
|
||||
v-if="dialogVisible"
|
||||
ref="dialogForm"
|
||||
:model="dialogForm"
|
||||
size="small"
|
||||
inline
|
||||
@submit.native.prevent
|
||||
style="height: 32px"
|
||||
>
|
||||
<el-form-item label="规格型号">
|
||||
<el-cascader
|
||||
v-model="typeIdList"
|
||||
|
|
@ -56,6 +64,33 @@
|
|||
:controls="false"
|
||||
style="width: 120px"
|
||||
/>
|
||||
<span v-else-if="column.prop == 'certificates'">
|
||||
<span style="color: #00a288; cursor: pointer" @click="handleFileUpload(row, 2)">上传</span>
|
||||
<span
|
||||
v-if="row.certificates && row.certificates.length > 0"
|
||||
style="color: #00a288; cursor: pointer; margin-left: 10px"
|
||||
@click="handleView(row, 2)"
|
||||
>查看</span
|
||||
>
|
||||
</span>
|
||||
<span v-else-if="column.prop == 'inspectionReports'">
|
||||
<span style="color: #00a288; cursor: pointer" @click="handleFileUpload(row, 3)">上传</span>
|
||||
<span
|
||||
v-if="row.inspectionReports && row.inspectionReports.length > 0"
|
||||
style="color: #00a288; cursor: pointer; margin-left: 10px"
|
||||
@click="handleView(row, 3)"
|
||||
>查看</span
|
||||
>
|
||||
</span>
|
||||
<span v-else-if="column.prop == 'purchaseInvoices'">
|
||||
<span style="color: #00a288; cursor: pointer" @click="handleFileUpload(row, 4)">上传</span>
|
||||
<span
|
||||
v-if="row.purchaseInvoices && row.purchaseInvoices.length > 0"
|
||||
style="color: #00a288; cursor: pointer; margin-left: 10px"
|
||||
@click="handleView(row, 4)"
|
||||
>查看</span
|
||||
>
|
||||
</span>
|
||||
<!-- 其他列默认显示文本 -->
|
||||
<span v-else>{{ row[column.prop] }}</span>
|
||||
</template>
|
||||
|
|
@ -63,20 +98,54 @@
|
|||
<el-table-column label="操作" align="center">
|
||||
<template slot-scope="{ row, $index }">
|
||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(index)" style="color: red"
|
||||
>删除</el-button
|
||||
>删除</el-button
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 上传 -->
|
||||
<el-dialog :title="uploadTitle" :visible.sync="uploadVisible" width="40%">
|
||||
<FileUpload
|
||||
v-model="fileList"
|
||||
:value="fileList"
|
||||
:limit="3"
|
||||
:fileSize="10"
|
||||
:fileType="['jpg', 'png', 'pdf']"
|
||||
@input="handleFileList"
|
||||
/>
|
||||
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="uploadVisible = false">关 闭</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
<!-- 查看 -->
|
||||
<el-dialog :title="viewTitle" :visible.sync="viewVisible" width="40%">
|
||||
<el-table :data="viewList" fit highlight-current-row style="width: 100%" height="546">
|
||||
<el-table-column type="index" width="55" label="序号" align="center" />
|
||||
<el-table-column label="附件名称" prop="fileName" align="center">
|
||||
<!-- 插槽 -->
|
||||
<template v-slot="{ row }">
|
||||
<span style="color: #00a288; cursor: pointer" @click="handleFile(row)">{{ row.fileName }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="viewVisible = false">关 闭</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getTreeSelectApi, addApplyCodeApi, addToolApi } from '@/api/toolsManage'
|
||||
import FileUpload from '@/components/FileImageUpload'
|
||||
|
||||
export default {
|
||||
components: { FileUpload },
|
||||
data() {
|
||||
return {
|
||||
isLoading: false,
|
||||
|
|
@ -96,11 +165,25 @@ export default {
|
|||
{ label: '计量单位', prop: 'unitName' },
|
||||
{ label: '单价', prop: 'originCost', width: 150 },
|
||||
{ label: '申请数量', prop: 'applyNum', width: 150 },
|
||||
{ label: '合格证', prop: 'certificates' },
|
||||
{ label: '检测证书', prop: 'inspectionReports' },
|
||||
{ label: '发票', prop: 'purchaseInvoices' },
|
||||
],
|
||||
dialogList: [],
|
||||
options: [],
|
||||
activeLabels: [],
|
||||
lastNode: null,
|
||||
certificates: [], // 合格证
|
||||
inspectionReports: [], // 检测证书
|
||||
purchaseInvoices: [], // 采购发票
|
||||
uploadType: '',
|
||||
currentRow: null,
|
||||
uploadTitle: '',
|
||||
uploadVisible: false,
|
||||
fileList: [],
|
||||
viewVisible: false,
|
||||
viewTitle: '',
|
||||
viewList: [],
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
|
@ -178,6 +261,9 @@ export default {
|
|||
unitName: this.lastNode.unitName || '',
|
||||
originCost,
|
||||
applyNum: 1,
|
||||
certificates: [], // 合格证
|
||||
inspectionReports: [], // 检测证书
|
||||
purchaseInvoices: [], // 采购发票
|
||||
})
|
||||
this.$message({
|
||||
type: 'success',
|
||||
|
|
@ -241,6 +327,75 @@ export default {
|
|||
this.isLoading = false
|
||||
}
|
||||
},
|
||||
handleFile(row) {
|
||||
// 打开文件预览
|
||||
window.open(row.fileUrl, '_blank')
|
||||
},
|
||||
// 查看
|
||||
handleView(row, type) {
|
||||
if (type == 2) {
|
||||
this.viewTitle = '合格证'
|
||||
this.viewList = row.certificates || []
|
||||
} else if (type == 3) {
|
||||
this.viewTitle = '检测证书'
|
||||
this.viewList = row.inspectionReports || []
|
||||
} else if (type == 4) {
|
||||
this.viewTitle = '采购发票'
|
||||
this.viewList = row.purchaseInvoices || []
|
||||
}
|
||||
this.viewVisible = true
|
||||
},
|
||||
// 上传
|
||||
handleFileUpload(row, type) {
|
||||
this.uploadType = type
|
||||
this.currentRow = row
|
||||
if (type == 2) {
|
||||
this.uploadTitle = '合格证'
|
||||
this.fileList = row.fileList2
|
||||
} else if (type == 3) {
|
||||
this.uploadTitle = '定期检验报告'
|
||||
this.fileList = row.fileList3
|
||||
} else if (type == 4) {
|
||||
this.uploadTitle = '采购发票'
|
||||
this.fileList = row.fileList4
|
||||
}
|
||||
this.uploadVisible = true
|
||||
},
|
||||
handleFileList(file) {
|
||||
console.log('🚀 ~ file:', file)
|
||||
if (this.uploadType == 2) {
|
||||
this.currentRow.fileList2 = file
|
||||
if (!file) {
|
||||
this.currentRow.certificates = []
|
||||
return
|
||||
}
|
||||
this.currentRow.certificates = this.formatFileList(file)
|
||||
} else if (this.uploadType == 3) {
|
||||
this.currentRow.fileList3 = file
|
||||
if (!file) {
|
||||
this.currentRow.inspectionReports = []
|
||||
return
|
||||
}
|
||||
this.currentRow.inspectionReports = this.formatFileList(file)
|
||||
} else if (this.uploadType == 4) {
|
||||
this.currentRow.fileList4 = file
|
||||
if (!file) {
|
||||
this.currentRow.purchaseInvoices = []
|
||||
return
|
||||
}
|
||||
this.currentRow.purchaseInvoices = this.formatFileList(file)
|
||||
}
|
||||
},
|
||||
formatFileList(file) {
|
||||
const arr = file.split(',')
|
||||
return arr.map((item) => {
|
||||
const parts = item.split('/')
|
||||
return {
|
||||
fileName: parts[parts.length - 1],
|
||||
fileUrl: item,
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,29 @@
|
|||
<div class="app-container">
|
||||
<el-card v-show="showSearch" style="margin-bottom: 20px">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" inline @submit.native.prevent>
|
||||
<el-form-item label="工具专业" prop="fourthParentId">
|
||||
<el-form-item label="管理模式" prop="manageMode">
|
||||
<el-select v-model="queryParams.manageMode" placeholder="请选择管理模式" clearable style="width: 240px">
|
||||
<el-option label="编码工具" value="0" />
|
||||
<el-option label="数量工具" value="1" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="工具类目"
|
||||
prop="typeIds"
|
||||
>
|
||||
<el-cascader
|
||||
v-model="queryParams.typeIds"
|
||||
:options="toolTreeData"
|
||||
:props="toolCascaderProps"
|
||||
placeholder="请选择工具类目"
|
||||
clearable
|
||||
style="width: 200px"
|
||||
filterable
|
||||
popper-class="six-level-cascader"
|
||||
@change="handleToolCategoryChange"
|
||||
/>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="工具专业" prop="fourthParentId">
|
||||
<el-select
|
||||
v-model="queryParams.fourthParentId"
|
||||
placeholder="请选择工具专业"
|
||||
|
|
@ -12,7 +34,7 @@
|
|||
@change="(val) => changeType(val, '2')"
|
||||
style="width: 240px"
|
||||
>
|
||||
<el-option v-for="item in fourthParentList" :key="item.id" :label="item.label" :value="item.id"/>
|
||||
<el-option v-for="item in fourthParentList" :key="item.id" :label="item.label" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="施工类型" prop="greatGrandparentId">
|
||||
|
|
@ -25,7 +47,7 @@
|
|||
@change="(val) => changeType(val, '3')"
|
||||
style="width: 240px"
|
||||
>
|
||||
<el-option v-for="item in greatGrandparentList" :key="item.id" :label="item.label" :value="item.id"/>
|
||||
<el-option v-for="item in greatGrandparentList" :key="item.id" :label="item.label" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="工具类型" prop="grandparentTypeId">
|
||||
|
|
@ -38,7 +60,7 @@
|
|||
@change="(val) => changeType(val, '4')"
|
||||
style="width: 240px"
|
||||
>
|
||||
<el-option v-for="item in grandparentTypeList" :key="item.id" :label="item.label" :value="item.id"/>
|
||||
<el-option v-for="item in grandparentTypeList" :key="item.id" :label="item.label" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="工具名称" prop="parentTypeId">
|
||||
|
|
@ -50,9 +72,9 @@
|
|||
:disabled="!queryParams.grandparentTypeId"
|
||||
style="width: 240px"
|
||||
>
|
||||
<el-option v-for="item in parentTypeList" :key="item.id" :label="item.label" :value="item.id"/>
|
||||
<el-option v-for="item in parentTypeList" :key="item.id" :label="item.label" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form-item> -->
|
||||
<el-form-item label="规格型号" prop="typeName">
|
||||
<el-input
|
||||
v-model="queryParams.typeName"
|
||||
|
|
@ -77,16 +99,10 @@
|
|||
<!-- <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport">导出数据</el-button> -->
|
||||
<div style="font-size: 20; font-weight: 800">工具台账列表</div>
|
||||
</el-col>
|
||||
<el-button
|
||||
icon="el-icon-download"
|
||||
style="margin-left: 1320px"
|
||||
type="primary"
|
||||
size="mini"
|
||||
@click="handleExport"
|
||||
>
|
||||
<el-button icon="el-icon-download" style="margin-left: 1320px" type="primary" size="mini" @click="handleExport">
|
||||
导出数据
|
||||
</el-button>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"/>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList" />
|
||||
</el-row>
|
||||
|
||||
<el-table
|
||||
|
|
@ -124,7 +140,6 @@
|
|||
|
||||
<!-- 分页 -->
|
||||
<pagination
|
||||
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
|
|
@ -136,7 +151,7 @@
|
|||
<el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="70%">
|
||||
<el-form ref="dialogForm" :model="dialogForm" label-width="" size="small" inline @submit.native.prevent>
|
||||
<el-form-item label="关键字" prop="keyWord">
|
||||
<el-input v-model="dialogForm.keyWord" placeholder="请输入关键字" clearable/>
|
||||
<el-input v-model="dialogForm.keyWord" placeholder="请输入关键字" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" @click="handleDialogQuery">查询</el-button>
|
||||
|
|
@ -185,7 +200,6 @@
|
|||
</el-table>
|
||||
<!-- 分页 -->
|
||||
<pagination
|
||||
|
||||
:total="dlgTotal"
|
||||
:page.sync="dialogForm.pageNum"
|
||||
:limit.sync="dialogForm.pageSize"
|
||||
|
|
@ -201,7 +215,7 @@
|
|||
|
||||
<script>
|
||||
import { getToolLedgerListApi, getToolSelectApi, getToolByTypeIdApi, getToolByProApi } from '@/api/toolsManage'
|
||||
import { formatTime } from '@/utils/bonus'
|
||||
import { getTreeSelectApi } from '@/api/toolsManage/index.js'
|
||||
|
||||
export default {
|
||||
name: 'ToolsLedger',
|
||||
|
|
@ -212,7 +226,7 @@ export default {
|
|||
pickerOptions: {
|
||||
disabledDate(time) {
|
||||
return time.getTime() > Date.now()
|
||||
}
|
||||
},
|
||||
},
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
|
|
@ -223,8 +237,19 @@ export default {
|
|||
greatGrandparentId: null, // 施工类型
|
||||
grandparentTypeId: null, // 工具类型
|
||||
parentTypeId: null, // 工具名称
|
||||
typeName: null // 规格型号
|
||||
typeName: null, // 规格型号
|
||||
manageMode: '',
|
||||
typeId: null,
|
||||
typeIds: null,
|
||||
},
|
||||
toolCascaderProps: {
|
||||
value: 'typeId',
|
||||
label: 'typeName',
|
||||
children: 'children',
|
||||
checkStrictly: true,
|
||||
expandTrigger: 'click'
|
||||
},
|
||||
toolTreeData: [], // 工具分类树
|
||||
fourthParentList: [],
|
||||
greatGrandparentList: [],
|
||||
grandparentTypeList: [],
|
||||
|
|
@ -243,15 +268,15 @@ export default {
|
|||
render: (h, { row }) => {
|
||||
return row.manageMode == 0 && row.availableNum > 0
|
||||
? h(
|
||||
'span',
|
||||
{
|
||||
style: { color: '#409EFF', cursor: 'pointer' },
|
||||
on: { click: () => this.handleDialog(row, '0') }
|
||||
},
|
||||
row.availableNum
|
||||
)
|
||||
'span',
|
||||
{
|
||||
style: { color: '#409EFF', cursor: 'pointer' },
|
||||
on: { click: () => this.handleDialog(row, '0') },
|
||||
},
|
||||
row.availableNum,
|
||||
)
|
||||
: h('span', {}, row.availableNum)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '自用数量',
|
||||
|
|
@ -259,15 +284,15 @@ export default {
|
|||
render: (h, { row }) => {
|
||||
return row.inNum > 0
|
||||
? h(
|
||||
'span',
|
||||
{
|
||||
style: { color: '#409EFF', cursor: 'pointer' },
|
||||
on: { click: () => this.handleDialog(row, '3') }
|
||||
},
|
||||
row.inNum
|
||||
)
|
||||
'span',
|
||||
{
|
||||
style: { color: '#409EFF', cursor: 'pointer' },
|
||||
on: { click: () => this.handleDialog(row, '3') },
|
||||
},
|
||||
row.inNum,
|
||||
)
|
||||
: h('span', {}, row.inNum)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '共享数量',
|
||||
|
|
@ -275,15 +300,15 @@ export default {
|
|||
render: (h, { row }) => {
|
||||
return row.shareNum > 0
|
||||
? h(
|
||||
'span',
|
||||
{
|
||||
style: { color: '#409EFF', cursor: 'pointer' },
|
||||
on: { click: () => this.handleDialog(row, '1') }
|
||||
},
|
||||
row.shareNum
|
||||
)
|
||||
'span',
|
||||
{
|
||||
style: { color: '#409EFF', cursor: 'pointer' },
|
||||
on: { click: () => this.handleDialog(row, '1') },
|
||||
},
|
||||
row.shareNum,
|
||||
)
|
||||
: h('span', {}, row.shareNum)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '在修数量',
|
||||
|
|
@ -291,18 +316,19 @@ export default {
|
|||
render: (h, { row }) => {
|
||||
return row.manageMode == 0 && row.repairNum > 0
|
||||
? h(
|
||||
'span',
|
||||
{
|
||||
style: { color: '#409EFF', cursor: 'pointer' },
|
||||
on: { click: () => this.handleDialog(row, '2') }
|
||||
},
|
||||
row.repairNum
|
||||
)
|
||||
'span',
|
||||
{
|
||||
style: { color: '#409EFF', cursor: 'pointer' },
|
||||
on: { click: () => this.handleDialog(row, '2') },
|
||||
},
|
||||
row.repairNum,
|
||||
)
|
||||
: h('span', {}, row.repairNum)
|
||||
}
|
||||
}, {
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '退役数量',
|
||||
prop: 'scrapNum'
|
||||
prop: 'scrapNum',
|
||||
},
|
||||
{ label: '工具总数(不含退役数)', prop: 'totalNum' },
|
||||
{
|
||||
|
|
@ -310,8 +336,8 @@ export default {
|
|||
prop: 'manageMode',
|
||||
render: (h, { row }) => {
|
||||
return row.manageMode == '1' ? h('span', {}, '数量管理') : h('span', {}, '编码管理')
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
// 表格数据
|
||||
tableList: [],
|
||||
|
|
@ -321,7 +347,7 @@ export default {
|
|||
dialogForm: {
|
||||
keyWord: '',
|
||||
pageNum: 1,
|
||||
pageSize: 10
|
||||
pageSize: 10,
|
||||
},
|
||||
dlgTotal: 0, // 弹框总条数
|
||||
dialogColumns: [
|
||||
|
|
@ -332,23 +358,24 @@ export default {
|
|||
prop: 'toolCode',
|
||||
render: (h, { row }) => {
|
||||
return row.toolCode ? h('span', {}, row.toolCode) : h('span', {}, '-')
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '数量',
|
||||
prop: 'totalNum',
|
||||
render: (h, { row }) => {
|
||||
return row.totalNum ? h('span', {}, row.totalNum) : h('span', {}, '1')
|
||||
}
|
||||
},
|
||||
},
|
||||
{ label: '所在工程', prop: 'proName' }
|
||||
{ label: '所在工程', prop: 'proName' },
|
||||
],
|
||||
dialogList: []
|
||||
dialogList: [],
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getList()
|
||||
this.getSelectList()
|
||||
this.getToolTree()
|
||||
},
|
||||
methods: {
|
||||
// 查询
|
||||
|
|
@ -496,12 +523,46 @@ export default {
|
|||
* 导出数据
|
||||
*/
|
||||
handleExport() {
|
||||
this.download('/material-mall/toolLedger/exportAll', {
|
||||
...this.queryParams
|
||||
}, `工具台账_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
|
||||
}
|
||||
this.download(
|
||||
'/material-mall/toolLedger/exportAll',
|
||||
{
|
||||
...this.queryParams,
|
||||
},
|
||||
`工具台账_${new Date().getTime()}.xlsx`,
|
||||
)
|
||||
},
|
||||
// 获取工具分类树数据(适配返回字段,限制最多6级)
|
||||
async getToolTree() {
|
||||
try {
|
||||
const res = await getTreeSelectApi()
|
||||
if (res.code === 200) {
|
||||
let rawData = res.data || []
|
||||
this.toolTreeData = this.processToolTreeData(rawData)
|
||||
} else {
|
||||
this.$message.error(res.msg || '获取工具分类失败')
|
||||
}
|
||||
} catch (error) {
|
||||
this.$message.error('获取工具分类数据失败:' + (error.message || '未知错误'))
|
||||
}
|
||||
},
|
||||
// 递归处理工具分类节点(限制六级)
|
||||
processToolTreeData(data, currentLevel = 1) {
|
||||
if (currentLevel > 6) return []
|
||||
return data.map(item => {
|
||||
const processedItem = { ...item }
|
||||
// 六级以下递归处理子节点
|
||||
if (item.children && item.children.length > 0 && currentLevel < 6) {
|
||||
processedItem.children = this.processToolTreeData(item.children, currentLevel + 1)
|
||||
} else {
|
||||
delete processedItem.children // 超过六级移除子节点
|
||||
}
|
||||
return processedItem
|
||||
})
|
||||
},
|
||||
handleToolCategoryChange(val) {
|
||||
this.queryParams.typeId = val[val.length - 1] || ''
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue