Commit 0f178f0a by crushh

udpate: dist

parent b8eae1e3
/**
* 解析property
* @param {Number | String} val property值,也可能是多个对应值之和
* @return {Object} map
* @return {Boolean} map.isCompute 是否是计算属性
* @return {Boolean} map.isField 是否是字段属性
* @return {Boolean} map.isValue 是否是值属性
* @return {Boolean} map.isCategray 是否是不是属性
* @return {Boolean} map.notProperty 是否是类别属性
*/
export default val => {
// 用二进制对应位上的1表示对应属性的开启状态
// {
// 1: '0001', // 计算属性
// 2: '0010', // 字段属性
// 4: '0100', // 值属性
// 8: '1000', // 不是属性
// 16: '00010000', // 类别属性
// }
// 将val转为二进制,来处理值之和的情况,例如:3 = 1 + 2 = 0001 + 0010 = 0011
// 然后再把二进制值的字符串转为数字,调转顺序,0 1转为bool
const status = Number(val).toString(2).split('').reverse().map(i => i == 1)
// 根据上面的键值对表,从二进制最末一位开始,对应在数组里
const keys = ['isCompute', 'isField', 'isValue', 'isCategray', 'notProperty']
// 根据数组转换出状态结果
return keys.reduce((map, key, index) => ({ ...map, [key]: !!status[index] }), {});
}
......@@ -5,20 +5,20 @@
<el-tabs tab-position="left" @tab-click="onTabsClick" v-model="activeName">
<el-tab-pane :label="item.chainNodeName" v-for="item in conditionTypeList" :key="item.esScreeningWidgetChainId" :name="item.esScreeningWidgetChainId">
<div v-if="templateCode == 'tag001'" class="leftContent">
<el-checkbox-group v-model="selectData[item.chainNodeName]" @change="handleChange" class="checkBoxContainer">
<el-checkbox v-for="row in checkboxList" :key="row.key" :label="row.key">{{ row.value }}</el-checkbox>
<el-checkbox-group v-model="item.selectValue" @change="val => handleChange(val, item.esScreeningWidgetChainId)" class="checkBoxContainer">
<el-checkbox v-for="row in item.selectList" :key="row.key" :label="row.value">{{ row.value }}</el-checkbox>
</el-checkbox-group>
</div>
<div v-if="templateCode == 'com026'" class="leftContent">
<div class="line" v-for="(value, index) in checkboxList" :key="index">
<div class="line" v-for="(value, index) in item.selectList" :key="index">
<h3>{{ value.title }}</h3>
<el-checkbox-group v-model="selectData[item.chainNodeName]" @change="handleChange" class="checkBoxContainer">
<el-checkbox-group v-model="item.selectValue" @change="val => handleChange(val, item.esScreeningWidgetChainId)" class="checkBoxContainer">
<el-checkbox v-for="row in value.data" :key="row.key" :label="row.value">{{ row.key }}</el-checkbox>
</el-checkbox-group>
</div>
</div>
<div v-if="templateCode == 'com020'" class="leftContent">
<dm-store-selector style="margin-top: 20px;" ref="newStoreCard" :uuid.sync="uuid"></dm-store-selector>
<vue-gic-store-new :isAdd="isAdd" :creatorId="creatorId" :scenesVal="scenes" scenes="auth" :uuid="item.value" ref="storeNew" @store-change="storeChange"></vue-gic-store-new>
</div>
</el-tab-pane>
</el-tabs>
......@@ -28,13 +28,10 @@
已选条件
</div>
<ul class="right-content">
<li class="contact-li" v-for="(value, name) in selectData" :key="name">
{{ name }}
<div class="li-cell cursor-pointer">
<div>
<span v-for="item in value" :key="item"> {{ item }}</span>
</div>
<i v-if="!readonly" class="el-icon-close" @click="deleteRow(item)"></i>
<li class="contact-li" v-for="(item, index) in selectData" :key="index">
<div class="li-cell cursor-pointer">{{ item.chainNodeName }} <i v-if="!readonly" class="el-icon-close" @click="deleteRow(item)"></i></div>
<div>
<span v-for="row in item.selectValue" :key="row"> {{ row }}</span>
</div>
</li>
</ul>
......@@ -42,20 +39,20 @@
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="close">取消</el-button>
<el-button type="primary" @click="confirmTagsDialog">确定</el-button>
<el-button type="primary" @click="confirm">确定</el-button>
</div>
</el-dialog>
</template>
<script>
import qs from 'qs';
import parseProperty from './parse-property.js';
export default {
data() {
return {
activeName: '',
conditionTypeList: [], // 第一层级
checkboxList: [],
selectData: {},
arr: [],
uuid: '',
templateCode: '' //当前控件类型
......@@ -70,10 +67,23 @@ export default {
mounted() {
this.getDataList();
},
computed: {
selectData() {
const data = [];
this.conditionTypeList.forEach(item => {
data.push({ chainNodeName: item.chainNodeName, selectValue: item.selectValue });
});
return data;
}
},
methods: {
handleChange(val) {
handleChange(val, id) {
this.conditionTypeList.find(item => item.esScreeningWidgetChainId == id).value = val.join(',');
console.log(this.conditionTypeList);
},
storeChange(val) {
console.log(val);
this.selectData = Object.assign({}, this.selectData);
},
onTabsClick(val) {
console.log(val);
......@@ -83,6 +93,39 @@ export default {
close() {
this.$emit('update:visiable', false);
},
confirm() {
this.handleConfirmData();
// this.axios.post('/save-member-crowd-new', para).then(res => {});
},
handleConfirmData() {
let arr = [];
this.conditionTypeList.forEach(item => {
if (item.value) {
arr.push(this.getParamsData(item));
}
});
console.log(arr);
},
getParamsData(node) {
const result = { key: '', compute: '', value: '' };
const property = parseProperty(node.property);
if (property.isField) {
result.key = node.columnKey;
// console.log(result.key)
}
// isCompute 是否是计算属性
// 计算属性的值来源:computeCharacter或是选择的值
if (property.isCompute) {
result.compute = node.computeCharacter;
}
// notProperty 是否是类别属性
// 类别属性 dealkey有值就带上,和value key同级,如果没值要删掉
if (property.notProperty && node.dealKey) {
result.dealKey = node.dealKey;
}
result.value = node.value;
return result;
},
// 获取列表
getDataList() {
let para = {
......@@ -94,12 +137,21 @@ export default {
.then(res => {
let resData = res.data;
if (resData.errorCode == 0) {
this.conditionTypeList = resData.result;
this.activeName = this.conditionTypeList.length && this.conditionTypeList[0].esScreeningWidgetChainId;
this.conditionTypeList.forEach(item => {
this.selectData[item.chainNodeName] = [];
resData.result.forEach(item => {
const { chainNodeName, templateCode, esScreeningWidgetChainId, columnKey, computeCharacter, dealKey, property } = item;
this.conditionTypeList.push({
chainNodeName,
templateCode,
esScreeningWidgetChainId,
columnKey,
computeCharacter,
dealKey,
property,
selectValue: [],
selectList: []
});
});
this.activeName = this.conditionTypeList.length && this.conditionTypeList[0].esScreeningWidgetChainId;
this.getNode(this.activeName);
return;
}
......@@ -116,26 +168,27 @@ export default {
});
},
getNode(widgetChainId) {
// 第二层节点的控件类型
this.axios.get(`/api-plug/get-screening-widget-chain-detail?requestProject=gic-web&widgetChainId=${widgetChainId}`).then(res => {
const {
esScreeningWidgetChainId,
widget: { sourceFlag, templateCode, widgetParam, widgetValues },
widgetFieldKey
} = res.data.result; // 返回的结果 从第一层开始
this.templateCode = templateCode;
console.log(res.data.result);
if (sourceFlag == 1) {
// 有接口
const url = JSON.parse(widgetParam)[0].value;
this.getChildNode(url, widgetFieldKey);
this.getChildNode(url, widgetFieldKey, esScreeningWidgetChainId);
} else {
if (templateCode == 'tag001') {
this.checkboxList = JSON.parse(widgetValues);
this.conditionTypeList.find(item => item.esScreeningWidgetChainId == esScreeningWidgetChainId).selectList = JSON.parse(widgetValues);
}
}
});
},
// 获取下一层控件
getChildNode(url, key) {
// 使用接口获取 第二层控件类型的内容
getChildNode(url, key, id) {
const param = {
requestProject: 'gic-web',
key
......@@ -144,7 +197,7 @@ export default {
let resData = res.data;
console.log(resData.result);
if (resData.errorCode == 0) {
this.checkboxList = resData.result;
this.conditionTypeList.find(item => item.esScreeningWidgetChainId == id).selectList = resData.result;
}
});
}
......
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