|
|
|
@ -172,6 +172,10 @@ |
|
|
|
</el-col> |
|
|
|
<el-col :span="12"> |
|
|
|
<el-form-item label="备品备件编码"> |
|
|
|
<span slot="label"> |
|
|
|
备品备件编码 |
|
|
|
<el-button type="text" style="margin-left: 6px; padding: 0" @click="addModal">新增备品备件</el-button> |
|
|
|
</span> |
|
|
|
<el-input v-model="editData.partNo" placeholder="点击选择备品备件" readonly style="width: 100%" |
|
|
|
@click.native="openPartDialog('edit')"> |
|
|
|
<i slot="suffix" class="el-input__icon el-icon-search" @click="openPartDialog('edit')"></i> |
|
|
|
@ -218,13 +222,106 @@ |
|
|
|
<el-button @click="editDialogVisible = false">取消</el-button> |
|
|
|
</span> |
|
|
|
</el-dialog> |
|
|
|
|
|
|
|
<!-- 新增备品备件弹窗(与 partspare.vue 新增弹窗一致) --> |
|
|
|
<el-dialog title="备品备件" :close-on-click-modal="false" v-drag :visible.sync="modalFlag" width="520px"> |
|
|
|
<el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px;margin-top: -5px;"> |
|
|
|
<el-form-item label="BU" prop="bu"> |
|
|
|
<el-select v-model="modalData.bu" placeholder="请选择" :disabled="modalDisableFlag" @change="buChangeHandle" style="width: 221px"> |
|
|
|
<el-option |
|
|
|
v-for = "i in userBuList" |
|
|
|
:key = "i.buNo" |
|
|
|
:label = "i.sitename" |
|
|
|
:value = "i.buNo"> |
|
|
|
<span style="float: left;width: 100px">{{ i.sitename }}</span> |
|
|
|
<span style="float: right; color: #8492a6;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; font-size: 11px;width: 60px"> |
|
|
|
{{ i.buDesc }} |
|
|
|
</span> |
|
|
|
</el-option> |
|
|
|
</el-select> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="是否核心备件" prop="coreFlag"> |
|
|
|
<el-select v-model="modalData.coreFlag" style="width: 100px"> |
|
|
|
<el-option value="Y" label="是"></el-option> |
|
|
|
<el-option value="N" label="否"></el-option> |
|
|
|
</el-select> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="是否启用序列号管理" prop="sCodeControlFlag"> |
|
|
|
<el-select v-model="modalData.sCodeControlFlag" style="width: 130px"> |
|
|
|
<el-option value="Y" label="启用"></el-option> |
|
|
|
<el-option value="N" label="禁用"></el-option> |
|
|
|
</el-select> |
|
|
|
</el-form-item> |
|
|
|
</el-form> |
|
|
|
<el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px"> |
|
|
|
<el-form-item label="备品备件编码" prop="partNo"> |
|
|
|
<el-input :disabled="modalDisableFlag" v-model="modalData.partNo" style="width: 150px"></el-input> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="备品备件名称" prop="partDescription"> |
|
|
|
<el-input v-model="modalData.partDescription" style="width: 315px"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-form> |
|
|
|
<el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px"> |
|
|
|
<el-form-item label="状态" prop="active"> |
|
|
|
<el-select v-model="modalData.active" style="width: 109px"> |
|
|
|
<el-option value="Y" label="启用"></el-option> |
|
|
|
<el-option value="N" label="禁用"></el-option> |
|
|
|
</el-select> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="规格型号" prop="spec"> |
|
|
|
<el-input v-model="modalData.spec" style="width: 109px"></el-input> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="单价" prop="averagePrice"> |
|
|
|
<el-input-number :controls="false" :step="0" :min="0" v-model="modalData.averagePrice" style="width: 109px"></el-input-number> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="单位" prop="umid"> |
|
|
|
<el-input v-model="modalData.umid" style="width: 109px"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-form> |
|
|
|
<el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px"> |
|
|
|
<el-form-item label="产品组编码"> |
|
|
|
<el-input v-model="modalData.groupId" style="width: 109px"></el-input> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="预计使用寿命"> |
|
|
|
<el-input-number :controls="false" :step="0" :min="0" v-model="modalData.estUseQty" style="width: 109px"></el-input-number> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="最高库存数量"> |
|
|
|
<el-input-number :controls="false" :step="0" :min="0" v-model="modalData.maxStock" style="width: 109px"></el-input-number> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="最低库存数量" prop="minStock"> |
|
|
|
<el-input-number :controls="false" :step="0" :min="0" v-model="modalData.minStock" style="width: 109px"></el-input-number> |
|
|
|
</el-form-item> |
|
|
|
</el-form> |
|
|
|
<el-form :inline="true" label-position="top" :model="modalData" :rules="rules" style="margin-left: 7px"> |
|
|
|
<el-form-item prop="supplierName"> |
|
|
|
<span slot="label" @click="getBaseList(501)"><a herf="#">供应商编码</a></span> |
|
|
|
<el-input v-model="modalData.supplierName" style="width: 150px"></el-input> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item prop="warehouseId"> |
|
|
|
<span slot="label" style="" @click="getBaseList(502)"><a herf="#">仓库编码</a></span> |
|
|
|
<el-input v-model="modalData.warehouseId" style="width: 150px"></el-input> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item prop="locationId"> |
|
|
|
<el-link v-if="modalData.warehouseId" slot="label" @click="getBaseList(506)">货位编码</el-link> |
|
|
|
<span v-if="!modalData.warehouseId" slot="label">货位编码</span> |
|
|
|
<el-input v-model="modalData.locationId" style="width: 150px"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-form> |
|
|
|
<el-footer style="height:35px;margin-top: 15px;text-align:center"> |
|
|
|
<el-button type="primary" @click="saveData()">确定</el-button> |
|
|
|
<el-button type="primary" @click="modalFlag = false">取消</el-button> |
|
|
|
</el-footer> |
|
|
|
</el-dialog> |
|
|
|
|
|
|
|
<Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import * as XLSX from 'xlsx' |
|
|
|
import { getAllBuList } from '@/api/factory/site.js' |
|
|
|
import { getPartSpareList } from '@/api/partspare/partspare.js' |
|
|
|
import { getPartSpareList, savePartSpare, updatePartSpare, getMaxPartNo } from '@/api/partspare/partspare.js' |
|
|
|
import Chooselist from '@/views/modules/common/Chooselist_eam' |
|
|
|
import { |
|
|
|
queryPurchaseApplyPage, |
|
|
|
savePurchaseApply, |
|
|
|
@ -234,6 +331,9 @@ import { |
|
|
|
} from '@/api/partspare/partsparePurchase.js' |
|
|
|
|
|
|
|
export default { |
|
|
|
components: { |
|
|
|
Chooselist |
|
|
|
}, |
|
|
|
data () { |
|
|
|
return { |
|
|
|
userBuList: [], |
|
|
|
@ -271,7 +371,47 @@ export default { |
|
|
|
// 修改弹窗 |
|
|
|
editDialogVisible: false, |
|
|
|
editLoading: false, |
|
|
|
editData: this.getDefaultFormData() |
|
|
|
editData: this.getDefaultFormData(), |
|
|
|
// 新增备品备件弹窗(与 partspare.vue 一致) |
|
|
|
modalFlag: false, |
|
|
|
modalDisableFlag: false, |
|
|
|
tagNo: '', |
|
|
|
modalData: { |
|
|
|
flag: '', |
|
|
|
id: '', |
|
|
|
bu: '', |
|
|
|
active: '', |
|
|
|
coreFlag: '', |
|
|
|
averagePrice: '', |
|
|
|
estUseQty: 0, |
|
|
|
locationId: '', |
|
|
|
maxStock: 0, |
|
|
|
minStock: 0, |
|
|
|
partDescription: '', |
|
|
|
partNo: '', |
|
|
|
sCodeControlFlag: '', |
|
|
|
spec: '', |
|
|
|
supplierId: '', |
|
|
|
supplierName: '', |
|
|
|
umid: '', |
|
|
|
warehouseId: '', |
|
|
|
groupId: '' |
|
|
|
}, |
|
|
|
rules: { |
|
|
|
bu: [{ required: true, message: ' ', trigger: ['blur', 'change'] }], |
|
|
|
partNo: [{ required: true, message: ' ', trigger: ['blur', 'change'] }], |
|
|
|
partDescription: [{ required: true, message: ' ', trigger: ['blur', 'change'] }], |
|
|
|
active: [{ required: true, message: ' ', trigger: ['blur', 'change'] }], |
|
|
|
coreFlag: [{ required: true, message: ' ', trigger: ['blur', 'change'] }], |
|
|
|
spec: [{ required: true, message: ' ', trigger: ['blur', 'change'] }], |
|
|
|
sCodeControlFlag: [{ required: true, message: ' ', trigger: ['blur', 'change'] }], |
|
|
|
averagePrice: [{ required: true, message: ' ', trigger: ['blur', 'change'] }], |
|
|
|
umid: [{ required: true, message: ' ', trigger: ['blur', 'change'] }], |
|
|
|
minStock: [{ required: true, message: ' ', trigger: ['blur', 'change'] }], |
|
|
|
supplierName: [{ required: true, message: ' ', trigger: ['blur', 'change'] }], |
|
|
|
warehouseId: [{ required: true, message: ' ', trigger: ['blur', 'change'] }], |
|
|
|
locationId: [{ required: true, message: ' ', trigger: ['blur', 'change'] }] |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
computed: { |
|
|
|
@ -667,6 +807,205 @@ export default { |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
// 新增备品备件(打开与 partspare.vue 一致的新增弹窗) |
|
|
|
addModal () { |
|
|
|
this.modalData = { |
|
|
|
flag: '1', |
|
|
|
bu: (this.editData && this.editData.buKey) ? this.editData.buKey : (this.userBuList.length ? this.userBuList[0].buNo : ''), |
|
|
|
active: 'Y', |
|
|
|
coreFlag: 'N', |
|
|
|
averagePrice: 0, |
|
|
|
estUseQty: 0, |
|
|
|
locationId: '', |
|
|
|
maxStock: 0, |
|
|
|
minStock: 0, |
|
|
|
partDescription: (this.editData && this.editData.partDescription) ? this.editData.partDescription : '', |
|
|
|
partNo: '', |
|
|
|
sCodeControlFlag: 'N', |
|
|
|
spec: (this.editData && this.editData.spec) ? this.editData.spec : '', |
|
|
|
supplierId: '', |
|
|
|
supplierName: '', |
|
|
|
umid: '', |
|
|
|
warehouseId: '', |
|
|
|
groupId: '' |
|
|
|
} |
|
|
|
this.modalDisableFlag = false |
|
|
|
this.modalFlag = true |
|
|
|
// 自动填充备品备件编码(当前BU下最大值+1) |
|
|
|
this.loadMaxPartNo() |
|
|
|
}, |
|
|
|
|
|
|
|
// 加载当前BU下备品备件编码最大值+1 |
|
|
|
loadMaxPartNo () { |
|
|
|
if (this.modalData.flag !== '1') { |
|
|
|
return |
|
|
|
} |
|
|
|
if (this.modalData.bu === '' || this.modalData.bu == null) { |
|
|
|
return |
|
|
|
} |
|
|
|
getMaxPartNo({ bu: this.modalData.bu }).then(({data}) => { |
|
|
|
if (data && data.code === 0) { |
|
|
|
this.modalData.partNo = data.maxPartNo |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
// 新增弹窗切换BU时重新获取最大编码 |
|
|
|
buChangeHandle () { |
|
|
|
this.loadMaxPartNo() |
|
|
|
}, |
|
|
|
|
|
|
|
// 保存备品备件(与 partspare.vue saveData 一致) |
|
|
|
saveData () { |
|
|
|
if (this.modalData.bu === '' || this.modalData.bu == null) { |
|
|
|
this.$message.warning('请选择BU!') |
|
|
|
return |
|
|
|
} |
|
|
|
if (this.modalData.coreFlag === '' || this.modalData.coreFlag == null) { |
|
|
|
this.$message.warning('请选择是否核心备件!') |
|
|
|
return |
|
|
|
} |
|
|
|
if (this.modalData.sCodeControlFlag === '' || this.modalData.sCodeControlFlag == null) { |
|
|
|
this.$message.warning('请选择是否启用序列号管理!') |
|
|
|
return |
|
|
|
} |
|
|
|
if (this.modalData.partNo == null || this.modalData.partNo === '') { |
|
|
|
this.$message.warning("备品备件编码不能为空!") |
|
|
|
return |
|
|
|
} |
|
|
|
if (this.modalData.partDescription == null || this.modalData.partDescription === '') { |
|
|
|
this.$message.warning("备品备件名称不能为空!") |
|
|
|
return |
|
|
|
} |
|
|
|
if (this.modalData.active === '' || this.modalData.active == null) { |
|
|
|
this.$message.warning('请选择状态!') |
|
|
|
return |
|
|
|
} |
|
|
|
if (this.modalData.spec == null || this.modalData.spec === '') { |
|
|
|
this.$message.warning("规格型号不能为空!") |
|
|
|
return |
|
|
|
} |
|
|
|
if (this.modalData.averagePrice == null || this.modalData.averagePrice === '') { |
|
|
|
this.$message.warning("单价不能为空!") |
|
|
|
return |
|
|
|
} |
|
|
|
if (isNaN(this.modalData.averagePrice)) { |
|
|
|
this.$message.warning("单价必须为整数或小数!") |
|
|
|
return |
|
|
|
} |
|
|
|
if (this.modalData.umid == null || this.modalData.umid === '') { |
|
|
|
this.$message.warning("单位不能为空!") |
|
|
|
return |
|
|
|
} |
|
|
|
if (this.modalData.minStock == null || this.modalData.minStock === '') { |
|
|
|
this.$message.warning("最低库存数量不能为空!") |
|
|
|
return |
|
|
|
} |
|
|
|
if (this.modalData.supplierId == null || this.modalData.supplierId === '') { |
|
|
|
this.$message.warning("供应商编码不能为空!") |
|
|
|
return |
|
|
|
} |
|
|
|
if (this.modalData.warehouseId == null || this.modalData.warehouseId === '') { |
|
|
|
this.$message.warning("仓库编码不能为空!") |
|
|
|
return |
|
|
|
} |
|
|
|
if (this.modalData.locationId == null || this.modalData.locationId === '') { |
|
|
|
this.$message.warning("货位编码不能为空!") |
|
|
|
return |
|
|
|
} |
|
|
|
if (this.modalData.flag === '1') { |
|
|
|
savePartSpare(this.modalData).then(({data}) => { |
|
|
|
if (data && data.code === 0) { |
|
|
|
this.modalFlag = false |
|
|
|
this.$message({ |
|
|
|
message: '操作成功', |
|
|
|
type: 'success', |
|
|
|
duration: 1500, |
|
|
|
onClose: () => {} |
|
|
|
}) |
|
|
|
// 新增成功后将数据回填到修改采购申请表单 |
|
|
|
this.applyNewPartToEdit() |
|
|
|
} else { |
|
|
|
this.$alert(data.msg, '错误', { |
|
|
|
confirmButtonText: '确定' |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
} else { |
|
|
|
updatePartSpare(this.modalData).then(({data}) => { |
|
|
|
if (data && data.code === 0) { |
|
|
|
this.modalFlag = false |
|
|
|
this.$message({ |
|
|
|
message: '操作成功', |
|
|
|
type: 'success', |
|
|
|
duration: 1500, |
|
|
|
onClose: () => {} |
|
|
|
}) |
|
|
|
} else { |
|
|
|
this.$alert(data.msg, '错误', { |
|
|
|
confirmButtonText: '确定' |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
// 将新增的备品备件回填到修改采购申请弹窗 |
|
|
|
applyNewPartToEdit () { |
|
|
|
if (!this.editDialogVisible) { |
|
|
|
return |
|
|
|
} |
|
|
|
this.editData.partNo = this.modalData.partNo |
|
|
|
this.editData.partDescription = this.modalData.partDescription |
|
|
|
this.editData.spec = this.modalData.spec |
|
|
|
this.editData.umid = this.modalData.umid |
|
|
|
this.editData.supplierId = this.modalData.supplierId |
|
|
|
this.editData.supplierName = this.modalData.supplierName |
|
|
|
}, |
|
|
|
|
|
|
|
// 获取基础数据列表(供应商/仓库/货位) |
|
|
|
getBaseList (val, type) { |
|
|
|
this.tagNo = val |
|
|
|
this.$nextTick(() => { |
|
|
|
let strVal = '' |
|
|
|
let conSql = '' |
|
|
|
if (this.modalData.bu === null || this.modalData.bu === '') { |
|
|
|
this.$message.warning("请选择BU!") |
|
|
|
return |
|
|
|
} else { |
|
|
|
conSql = " and site = '" + this.modalData.bu.split('_')[0] + "'" + " and bu_no = '" + this.modalData.bu.split('_')[1] + "'" |
|
|
|
} |
|
|
|
if (val === 501) { |
|
|
|
strVal = this.modalData.supplierId |
|
|
|
conSql = " and site = '" + this.modalData.bu.split('_')[0] + "'" |
|
|
|
} |
|
|
|
if (val === 502) { |
|
|
|
strVal = this.modalData.warehouseId |
|
|
|
conSql = " and site = '" + this.modalData.bu.split('_')[0] + "'" + " and citem_code = '" + this.modalData.bu.split('_')[1] + "'" |
|
|
|
} |
|
|
|
if (val === 506) { |
|
|
|
strVal = this.modalData.locationId |
|
|
|
let whereValue = this.modalData.warehouseId ? "'" + this.modalData.warehouseId + "'" : "'*'" |
|
|
|
conSql = ' and warehouse_id = ' + whereValue |
|
|
|
} |
|
|
|
this.$refs.baseList.init(val, strVal, conSql) |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
// 列表方法的回调 |
|
|
|
getBaseData (val) { |
|
|
|
if (this.tagNo === 501) { |
|
|
|
this.modalData.supplierId = val.SupplierID |
|
|
|
this.modalData.supplierName = val.SupplierName |
|
|
|
} |
|
|
|
if (this.tagNo === 502) { |
|
|
|
this.modalData.warehouseId = val.warehouse_id |
|
|
|
} |
|
|
|
if (this.tagNo === 506) { |
|
|
|
this.modalData.locationId = val.location_id |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
// 删除 |
|
|
|
handleDelete (row) { |
|
|
|
if (!row) { |
|
|
|
|