Commit 74a014c3 authored by wangdanlei's avatar wangdanlei Committed by jingnan

串件单

parent ad705b5e
<template>
<div>
<el-select
v-model="selVal"
filterable
:disabled="disabled"
remote
placeholder="请输入"
:remote-method="remoteMethod"
:loading="loading"
@change="changeEvent"
>
<el-option
v-for="(item,i) in requestOp"
:key="i"
:label="item.label"
:value="item.value"
/>
</el-select>
</div>
</template>
<script>
import { post } from '@/utils/http'
export default {
componentName: '产品件号/型号选择',
name: 'ProductModelSelect',
components: {},
props: {
value: {
type: Object,
default: null
},
basicData: {
type: Object,
default: null
},
form: {
type: Object,
default: null
},
itemObj: {
type: Object,
default: null
}
},
data() {
return {
selVal: '',
linkageValue: '',
requestOp: [],
loading: false,
com: null
}
},
computed: {
disabled() {
let disabled = false
this.$utils.findByNameVnode(this, 'DeeAsForm').formData.forEach(item => {
item.data && item.data.forEach(x => {
if (x.key === this.itemObj.key) {
disabled = x.component.disabled
}
})
})
return disabled
}
},
watch: {
value: {
handler: function() {
if (Object.keys(this.basicData).length) {
this.setData(this.value)
}
},
deep: true
}
},
// 生命周期 - 创建完成(可以访问当前this 实例)
created() {
},
// 生命周期 - 挂载之前
beforeMount() {
},
// 生命周期 - 挂载完成(可以访问 DOM 元素)
mounted() {
// 流程里使用
if (Object.keys(this.basicData).length) {
this.setData(this.form.extMaterial)
}
},
methods: {
async setData(value) {
if (value) {
await this.getModelNo(value.modelNo)
this.selVal = JSON.stringify(value)
}
},
async getModelNo(query) {
const params = {
'pageFrom': 1,
'pageSize': 200,
'searchItems': {
'operator': 'AND',
'items': [{
'fieldName': 'modelNo',
'operator': 'LIKE',
'value': query
}]
},
'openProps': [
{
'name': 'extUnit'
}
]
}
await post(`/ExtDxProcessMaterial/search`, params)
.then(res => {
this.loading = false
if (res.code === 0) {
this.requestOp = res.items.content.map(item => {
return {
label: item.modelNo,
value: JSON.stringify(item)
}
})
}
})
},
changeEvent(value) {
const obj = JSON.parse(value)
this.$set(this.form, 'extMaterial', obj)
},
remoteMethod(query) {
if (query && query.length >= 2) {
if (this.time) {
this.time = null
}
this.time = setTimeout(() => {
this.loading = true
this.getModelNo(query)
}, 500)
}
}
}
}
</script>
<style lang='scss' scoped>
</style>
export default {
props: {},
layoutConfigData: [
{
title: '高级组件配置',
data: [
{
title: 'attrKey',
key: 'attrKey',
component: {
name: 'el-input',
placeholder: ''
}
},
{
title: '是否禁用',
key: 'disabled',
component: {
name: 'el-select',
options: [{
label: '是',
value: true
}, {
label: '否',
value: false
}]
}
}
]
}
],
data() {
return {
}
},
created() {
},
computed: {
},
methods: {
}
}
<template>
<div>
<el-select
v-model="selVal"
filterable
remote
:disabled="disabled"
placeholder="请输入"
:remote-method="remoteMethod"
:loading="loading"
@change="changeEvent"
>
<el-option
v-for="(item,i) in requestOp"
:key="i"
:label="item.label"
:value="item.value"
/>
</el-select>
</div>
</template>
<script>
import { post } from '@/utils/http'
import config from './config'
export default {
componentName: '装机指令号选择器',
name: 'SerialNumberSelect',
components: {},
mixins: [config],
props: {
basicData: {
type: Object,
default: null
},
value: {
type: Object,
default: null
},
form: {
type: Object,
default: null
},
itemObj: {
type: Object,
default: null
}
},
data() {
return {
selVal: '',
linkageValue: '',
requestOp: [],
loading: false
}
},
computed: {
disabled() {
return this.itemObj.disabled
}
},
watch: {
value() {
if (typeof this.value !== 'string') {
if (Object.keys(this.basicData).length) {
this.setData(this.value)
}
}
}
},
// 生命周期 - 创建完成(可以访问当前this 实例)
created() {
},
// 生命周期 - 挂载之前
beforeMount() {
},
// 生命周期 - 挂载完成(可以访问 DOM 元素)
mounted() {
this.com = this.$utils.findByNameVnode(this, 'DeeAsForm')
if (Object.keys(this.basicData).length) {
this.setData(this.form.sourceAo)
}
},
methods: {
async setData(value) {
let data = value
// 处理串件单类型等于库房串件时 source1(source必填,source1非必填)的回显问题
if (this.itemObj.attrKey.includes('targetAo') && this.form.replaceDocType === '库房串件') {
data = this.form.targetAo
}
if (data) {
await this.getModelNo(data.serialNumber)
this.selVal = JSON.stringify(data)
}
},
async getModelNo(query) {
const params = {
'pageFrom': 1,
'pageSize': 200,
'searchItems': {
'operator': 'AND',
'items': [{
'fieldName': 'serialNumber',
'operator': 'LIKE',
'value': query
}]
},
'openProps': [
{
'name': 'extUnit'
}
]
}
await post(`/ExtProcessPlan/search`, params)
.then(res => {
this.loading = false
if (res.code === 0) {
this.requestOp = res.items.content.map(item => {
return {
label: item.serialNumber,
value: JSON.stringify(item)
}
})
}
})
},
changeEvent(value) {
this.$set(this.form, this.itemObj.key, value)
},
remoteMethod(query) {
if (query && query.length >= 2) {
if (this.time) {
this.time = null
}
this.time = setTimeout(() => {
this.loading = true
this.getModelNo(query)
}, 500)
}
}
}
}
</script>
<style lang='scss' scoped>
</style>
export default {
props: {},
layoutConfigData: [
{
title: '高级组件配置',
data: [
{
title: 'attrKey',
key: 'attrKey',
component: {
name: 'el-input',
placeholder: ''
}
}
]
}
],
data() {
return {
}
},
created() {
},
computed: {
},
methods: {
}
}
<template>
<div>
<el-select
v-model="selVal"
:disabled="disabled"
placeholder="请选择"
>
<el-option
v-for="(item,i) in requestOp"
:key="i"
:label="item.label"
:value="item.value"
/>
</el-select>
</div>
</template>
<script>
import { get, post } from '@/utils/http'
import config from './config'
export default {
componentName: '串件架次选择',
name: 'SerialPieceSorties',
components: {},
mixins: [config],
props: {
value: {
type: String,
default: ''
},
basicData: {
type: Object,
default: null
},
form: {
type: Object,
default: null
},
itemObj: {
type: Object,
default: null
},
componentProp: {
type: Object,
default: () => { return {} }
}
},
data() {
return {
selVal: '',
linkageValue: '',
requestOp: [],
loading: false,
com: null
}
},
computed: {
disabled() {
let disabled = false
this.$utils.findByNameVnode(this, 'DeeAsForm').formData.forEach(item => {
item.data && item.data.forEach(x => {
if (x.key === this.itemObj.attrKey) {
disabled = x.component.disabled
}
})
})
return disabled
}
},
watch: {
'form.aircraftType': function(val) {
this.getSortiesByCode(val)
},
'form.extMaterial': function(val) {
this.findCanReplaceSerno(val.id, this.selVal)
},
selVal(val) {
this.$set(this.form, this.itemObj.key, val)
let obj = this.form
const keyList = this.itemObj.key.split('.')
keyList.forEach((item, i) => {
if (i < keyList.length - 1) {
if (!obj[item]) {
obj[item] = {}
this.$set(obj, item, {})
obj = obj[item]
}
} else {
this.$set(obj, item, val)
}
})
if (this.form.extMaterial) {
this.findCanReplaceSerno(this.form.extMaterial.id, val)
}
}
},
// 生命周期 - 创建完成(可以访问当前this 实例)
created() {
},
// 生命周期 - 挂载之前
beforeMount() {
},
// 生命周期 - 挂载完成(可以访问 DOM 元素)
mounted() {
this.com = this.$utils.findByNameVnode(this, 'DeeAsForm')
if (Object.keys(this.basicData).length) {
this.setData(this.form.aircraftType)
}
},
methods: {
async setData(value) {
await this.getSortiesByCode(value)
if (this.itemObj.key.includes('source')) {
this.selVal = this.basicData.sourceSorties
} else {
this.selVal = this.basicData.targetSorties
}
},
async getSortiesByCode(val) {
await get(`/AircraftSorties/getSortiesByCode?aircraftType=${val}&aircraftTypeId=${val}`)
.then(res => {
this.loading = false
if (res.code === 0) {
this.requestOp = res.items.map(item => {
return {
label: item.defName,
value: item.defCode
}
})
}
})
},
findCanReplaceSerno(materialId, sorties) {
if (materialId && sorties) {
post(`/Inventory/findCanReplaceSerno?materialId=${materialId}&sorties=${sorties}`)
.then(res => {
this.loading = false
if (res.code === 0) {
const keyList = Object.keys(res.items)
let attrKey = 'sourceSerno'
if (this.itemObj.key.includes('source')) {
this.form.sourceInventoryMap = res.items
} else {
this.form.targetInventoryMap = res.items
attrKey = 'targetSerno'
}
let options = []
if (keyList.length) {
options = keyList.map(key => {
return {
label: key,
value: key
}
})
} else {
if (this.itemObj.key.includes('source')) {
this.$set(this.form, 'sourceSerno', '')
this.$set(this.form, 'sourceApprovalCert', '')
this.$set(this.form, 'sourceProductDrawver', '')
this.$set(this.form, 'sourceElecHardwareNo', '')
this.$set(this.form, 'sourceSoftConfPieceNo', '')
} else {
this.$set(this.form, 'targetSerno', '')
this.$set(this.form, 'targetApprovalCert', '')
this.$set(this.form, 'targetProductDrawver', '')
this.$set(this.form, 'targetElecHardwareNo', '')
this.$set(this.form, 'targetSoftConfPieceNo', '')
}
}
this.com.formData.forEach(item => {
item.data && item.data.forEach(x => {
if (x.key === attrKey) {
this.$set(x.component, 'options', options)
}
})
})
}
})
}
}
}
}
</script>
<style lang='scss' scoped>
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment