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.
414 lines
13 KiB
414 lines
13 KiB
<template>
|
|
<div>
|
|
<div style="margin-top: 5px">
|
|
<el-button type="primary" @click="clickSave">{{ attributeDialog?'编辑':'保存' }}</el-button>
|
|
<el-button type="primary" @click="refreshPropertiesModal" :disabled="disabled" v-if="attributeDialog">刷新属性模板</el-button>
|
|
</div>
|
|
<div class="rq " v-if="attributeDialog">
|
|
<el-table
|
|
:height="height"
|
|
:data="dataList"
|
|
border
|
|
style="width: 100%;margin-top: 5px">
|
|
<el-table-column
|
|
v-for="(item,index) in productColumnList" :key="index"
|
|
:sortable="item.columnSortable"
|
|
:prop="item.columnProp"
|
|
:header-align="item.headerAlign"
|
|
:show-overflow-tooltip="item.showOverflowTooltip"
|
|
:align="item.align"
|
|
:fixed="item.fixed===''?false:item.fixed"
|
|
:min-width="item.columnWidth"
|
|
:label="item.columnLabel">
|
|
<template slot-scope="scope">
|
|
<div v-if="item.columnProp !== 'textValue' && item.columnProp !== 'numValue'">
|
|
<span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span>
|
|
<span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
|
|
</div>
|
|
<div v-else>
|
|
{{scope.row.valueTypeDb==='T'?scope.row.textValue:scope.row.numValue}}
|
|
</div>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
</div>
|
|
<div class="rq " v-else>
|
|
<el-table
|
|
:height="height"
|
|
:data="copyAttributeList"
|
|
border
|
|
style="width: 100%;margin-top: 5px">
|
|
<el-table-column
|
|
v-for="(item,index) in productColumnList" :key="index"
|
|
:sortable="item.columnSortable"
|
|
:prop="item.columnProp"
|
|
:header-align="item.headerAlign"
|
|
:show-overflow-tooltip="item.showOverflowTooltip"
|
|
:align="item.align"
|
|
:fixed="item.fixed===''?false:item.fixed"
|
|
:min-width="item.columnWidth"
|
|
:label="item.columnLabel">
|
|
<template slot-scope="scope">
|
|
<div v-if="item.columnProp !== 'textValue' && item.columnProp !== 'numValue'">
|
|
<span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span>
|
|
<span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
|
|
</div>
|
|
<div v-else>
|
|
<div v-if="scope.row.valueChooseFlag !== 'Y'">
|
|
<el-input-number v-model="scope.row.numValue" style="padding: 0;width: 100%" v-if="scope.row.valueType === '数字'" :controls="false"
|
|
></el-input-number>
|
|
<el-input v-model="scope.row.textValue" v-else></el-input>
|
|
</div>
|
|
<div v-else>
|
|
<el-select style="width: 100%;" v-if="scope.row.valueType === '文本'" v-model="scope.row.textValue">
|
|
<el-option :value="i.availableValue" :label="i.availableValue" v-for="(i,key) in scope.row.availableValueList" :key="key"></el-option>
|
|
</el-select>
|
|
<el-select style="width: 100%;" v-else v-model="scope.row.numValue">
|
|
<el-option :value="i.availableValue" :label="i.availableValue" v-for="(i,key) in scope.row.availableValueList" :key="key"></el-option>
|
|
</el-select>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
</div>
|
|
<el-dialog title="属性项目" v-drag :visible.sync="attributeSaveDialog" append-to-body>
|
|
<transfer-table v-if="attributeSaveDialog"
|
|
v-model="dataList2"
|
|
:data-list="searchDataList"> </transfer-table>
|
|
<el-footer style="height:40px;margin-top: 20px;text-align:center">
|
|
<el-button type="primary" @click="attributeSaveDialog = false">关闭</el-button>
|
|
</el-footer>
|
|
</el-dialog>
|
|
</div>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
import {
|
|
refreshPropertiesModal,
|
|
updatePropertiesList,
|
|
getPropertiesListByPartAndCodeNo,
|
|
searchPropertiesItemList,
|
|
saveSubPropertiesValueForAlone,
|
|
deleteSubPropertiesValueForAlone
|
|
} from "@/api/part/partProperties.js";
|
|
|
|
import TransferTable from "@/views/modules/common/transferTable.vue";
|
|
|
|
export default {
|
|
name: "orderAttribute",
|
|
components: {TransferTable},
|
|
props:{
|
|
site:{
|
|
type:String,
|
|
},
|
|
partNo:{
|
|
type:String,
|
|
},
|
|
codeNo:{
|
|
type:String,
|
|
},
|
|
functionType:{
|
|
type:String,
|
|
},
|
|
disabled:{
|
|
type:Boolean,
|
|
default:false,
|
|
}
|
|
},
|
|
data(){
|
|
return{
|
|
height:320,
|
|
loading:false,
|
|
attributeDialog:true,
|
|
copyAttributeList:[],
|
|
attributeSaveDialog:false,
|
|
productColumnList: [
|
|
{
|
|
userId: this.$store.state.user.name,
|
|
functionId: 100002001,
|
|
serialNumber: '100002001TablePropertiesItemNo',
|
|
tableId: "100002001Table",
|
|
tableName: "属性表",
|
|
columnProp: 'propertiesItemNo',
|
|
headerAlign: "center",
|
|
align: "left",
|
|
columnLabel: '属性编码',
|
|
columnHidden: false,
|
|
columnImage: false,
|
|
columnSortable: false,
|
|
sortLv: 0,
|
|
status: true,
|
|
fixed: '',
|
|
},{
|
|
userId: this.$store.state.user.name,
|
|
functionId: 100002001,
|
|
serialNumber: '100002001TableItemDesc',
|
|
tableId: "100002001Table",
|
|
tableName: "属性表",
|
|
columnProp: 'itemDesc',
|
|
headerAlign: "center",
|
|
align: "left",
|
|
columnLabel: '属性名称',
|
|
columnHidden: false,
|
|
columnImage: false,
|
|
columnSortable: false,
|
|
sortLv: 0,
|
|
status: true,
|
|
fixed: '',
|
|
},
|
|
{
|
|
userId: this.$store.state.user.name,
|
|
functionId: 100002001,
|
|
serialNumber: '100002001TableValueType',
|
|
tableId: "100002001Table",
|
|
tableName: "属性表",
|
|
columnProp: 'valueType',
|
|
headerAlign: "center",
|
|
align: "center",
|
|
columnLabel: '值类型',
|
|
columnHidden: false,
|
|
columnImage: false,
|
|
columnSortable: false,
|
|
sortLv: 0,
|
|
status: true,
|
|
fixed: '',
|
|
columnWidth:80,
|
|
},
|
|
|
|
{
|
|
userId: this.$store.state.user.name,
|
|
functionId: 100002001,
|
|
serialNumber: '100002001TableMaxValue',
|
|
tableId: "100002001Table",
|
|
tableName: "属性表",
|
|
columnProp: 'textValue',
|
|
headerAlign: "center",
|
|
align: "left",
|
|
columnLabel: '属性值',
|
|
columnHidden: false,
|
|
columnImage: false,
|
|
columnSortable: false,
|
|
sortLv: 0,
|
|
status: true,
|
|
fixed: '',
|
|
columnWidth:120,
|
|
},
|
|
|
|
],
|
|
searchDataList:[],
|
|
dataList:[],
|
|
dataList2:[],
|
|
}
|
|
},
|
|
watch:{
|
|
partNo(newValue,oldValue){
|
|
if (newValue){
|
|
this.getProperties();
|
|
}
|
|
},
|
|
},
|
|
methods:{
|
|
|
|
//初始化组件的参数
|
|
init(inData) {
|
|
//初始化参数
|
|
this.searchData = JSON.parse(JSON.stringify(inData));
|
|
//刷新表格
|
|
this.getProperties();
|
|
|
|
},
|
|
|
|
refreshPropertiesModal(){
|
|
this.$confirm(`是否刷新至最新模板界面,已填数据会更新到新模板中,若旧属性在新模板中被删除,该条数据会消失。`, '提示', {
|
|
confirmButtonText: '确定',
|
|
cancelButtonText: '取消',
|
|
type: 'warning'
|
|
}).then(() => {
|
|
let params = {
|
|
site: this.searchData.site,
|
|
partNo: this.searchData.partNo,
|
|
codeNo: this.searchData.codeNo,
|
|
recordType: this.searchData.functionType,
|
|
}
|
|
refreshPropertiesModal(params).then(({data}) => {
|
|
if (data && data.code === 0) {
|
|
this.$message.success(data.msg);
|
|
this.getProperties();
|
|
this.attributeDialog = true;
|
|
} else {
|
|
this.$message.warning(data.msg);
|
|
}
|
|
this.loading = false
|
|
}).catch((error) => {
|
|
this.$message.error(error)
|
|
this.loading = false
|
|
})
|
|
})
|
|
},
|
|
getProperties(){
|
|
let params = {
|
|
site: this.searchData.site,
|
|
partNo: this.searchData.partNo,
|
|
codeNo: this.searchData.codeNo,
|
|
recordType: this.searchData.functionType,
|
|
}
|
|
|
|
console.log("当前参数:",params)
|
|
getPropertiesListByPartAndCodeNo(params).then(({data})=>{
|
|
if (data && data.code === 0){
|
|
this.dataList = data.rows;
|
|
this.dataList2 = JSON.parse(JSON.stringify(data.rows));
|
|
for (let i = 0; i <this.dataList2.length ; i++) {
|
|
this.dataList2[i].itemNo= this.dataList2[i].propertiesItemNo
|
|
}
|
|
this.searchAttributeList({})
|
|
}else {
|
|
this.$message.warning(data.msg)
|
|
}
|
|
}).catch((error)=>{
|
|
this.$message.error(error)
|
|
})
|
|
},
|
|
clickSave(){
|
|
console.log("点击保存/编辑按钮,当前模式:", this.attributeDialog)
|
|
console.log("数据条数:", this.dataList.length)
|
|
console.log(0)
|
|
if(this.dataList.length===0) {
|
|
console.log("属性数据为空!")
|
|
return false
|
|
}
|
|
if(this.dataList.length===0){
|
|
return false
|
|
}
|
|
if (!this.attributeDialog){
|
|
this.updateTestPropertiesList();
|
|
}else {
|
|
//针对null 处理
|
|
for (let i = 0; i < this.dataList.length; i++){
|
|
if (this.dataList[i].numValue == null){
|
|
this.dataList[i].numValue = undefined;
|
|
}
|
|
}
|
|
this.copyAttributeList = JSON.parse(JSON.stringify(this.dataList))
|
|
this.attributeDialog = false;
|
|
}
|
|
|
|
},
|
|
|
|
updateTestPropertiesList(){
|
|
this.loading = true
|
|
updatePropertiesList(this.copyAttributeList).then(({data})=>{
|
|
if (data && data.code === 0){
|
|
this.$message.success(data.msg);
|
|
this.getProperties();
|
|
this.attributeDialog = true;
|
|
}else {
|
|
this.$message.warning(data.msg);
|
|
}
|
|
this.loading = false
|
|
}).catch((error)=>{
|
|
this.$message.error(error)
|
|
this.loading = false
|
|
})
|
|
},
|
|
clickSaveBtn(){
|
|
if (!this.attributeDialog) {
|
|
this.$message.warning('请保存更改!')
|
|
return
|
|
}
|
|
//查询 属性模板
|
|
this.searchAttributeList({})
|
|
this.attributeSaveDialog = true;
|
|
},
|
|
saveTestPropertiesItem(params){
|
|
let i = 0;
|
|
let arr = params.searchTableList.map(item=>{
|
|
item.partNo = this.searchData.partNo;
|
|
item.site = this.searchData.site;
|
|
item.codeNo = this.searchData.codeNo;
|
|
item.recordType = this.searchData.functionType;
|
|
return item
|
|
})
|
|
for (let j = 0; j <arr.length ; j++) {
|
|
arr[j].propertiesItemNo= arr[j].itemNo
|
|
arr[j].itemNo=999
|
|
}
|
|
saveSubPropertiesValueForAlone(arr).then(({data})=>{
|
|
if (data && data.code === 0){
|
|
this.$message.success(data.msg);
|
|
this.getProperties(params)
|
|
}else {
|
|
this.$message.warning(data.msg);
|
|
}
|
|
}).catch((error)=>{
|
|
this.$message.error(error)
|
|
})
|
|
},
|
|
removeTestPropertiesItem(params){
|
|
for (let i = 0; i <params.dataTableList.length ; i++) {
|
|
params.dataTableList[i].propertiesItemNo= params.dataTableList[i].itemNo
|
|
params.dataTableList[i].itemNo=999
|
|
}
|
|
deleteSubPropertiesValueForAlone(params.dataTableList).then(({data})=>{
|
|
if (data && data.code === 0){
|
|
this.$message.success(data.msg);
|
|
this.getProperties(params)
|
|
|
|
}else {
|
|
this.$message.warning(data.msg);
|
|
}
|
|
}).catch((error)=>{
|
|
this.$message.error(error)
|
|
})
|
|
},
|
|
searchAttributeList(data){
|
|
let params= JSON.parse(JSON.stringify(data))
|
|
params.site=this.$store.state.user.site;
|
|
params.list = this.dataList;
|
|
if (!this.attributeSaveDialog){
|
|
this.searchDataList = [];
|
|
}
|
|
let inData={
|
|
site: this.searchData.site,
|
|
partNo: this.searchData.partNo,
|
|
codeNo: this.searchData.codeNo,
|
|
functionType: this.searchData.functionType
|
|
|
|
}
|
|
searchPropertiesItemList(inData).then(({data}) => {
|
|
if (data && data.code === 0){
|
|
this.searchDataList = data.rows;
|
|
}else {
|
|
this.$message.warning(data.msg)
|
|
}
|
|
}).catch((error)=>{
|
|
this.$message.error(error)
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
created() {
|
|
// this.getProperties();
|
|
},
|
|
}
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
.el-input-number /deep/ .el-input__inner {
|
|
text-align: right;
|
|
padding-right: 5px !important;
|
|
}
|
|
|
|
/deep/ .el-input .el-input--medium{
|
|
line-height: 20px;
|
|
}
|
|
/deep/ .el-input-number .el-input--medium{
|
|
line-height: 20px;
|
|
}
|
|
</style>
|