新建工成
This commit is contained in:
36
common/api/gc.js
Normal file
36
common/api/gc.js
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import request from '../js/request';
|
||||||
|
import config from '../js/config';
|
||||||
|
|
||||||
|
export function addEngineering(params, files) {
|
||||||
|
return request({
|
||||||
|
url: '/engineering/addEngineering',
|
||||||
|
method: 'post',
|
||||||
|
data: params,
|
||||||
|
header: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export function auditEngineering(params) {
|
||||||
|
return request({
|
||||||
|
url: '/engineering/auditEngineering',
|
||||||
|
method: 'post',
|
||||||
|
data: params,
|
||||||
|
header: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function queryEngineering(params) {
|
||||||
|
return request({
|
||||||
|
url: '/engineering/queryEngineering',
|
||||||
|
method: 'post',
|
||||||
|
data: params,
|
||||||
|
header: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -8,12 +8,12 @@
|
|||||||
v-for="(item, index) in store.data" :key="index">
|
v-for="(item, index) in store.data" :key="index">
|
||||||
<view class="term-list-bottom">
|
<view class="term-list-bottom">
|
||||||
<view class="term-list-bottom-item">
|
<view class="term-list-bottom-item">
|
||||||
<view>设备个数</view>
|
<view>区域</view>
|
||||||
<view>3</view>
|
<view>{{ item.province +item.city}}</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="term-list-bottom-item">
|
<view class="term-list-bottom-item">
|
||||||
<view>用户个数</view>
|
<view>创建时间</view>
|
||||||
<view>1</view>
|
<view>{{ item.createTime}}</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</uni-card>
|
</uni-card>
|
||||||
@@ -35,7 +35,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
init () {
|
init () {
|
||||||
this.store = this.DataSource('/engineering/queryEngineering')
|
this.store = this.DataSource('/engineering/queryEngineeringPage')
|
||||||
this.store.params.userId = uni.getStorageSync('userInfo').id
|
this.store.params.userId = uni.getStorageSync('userInfo').id
|
||||||
this.store.reload()
|
this.store.reload()
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -5,15 +5,16 @@
|
|||||||
<view class="content">
|
<view class="content">
|
||||||
<uni-forms :label-width="80">
|
<uni-forms :label-width="80">
|
||||||
<uni-forms-item label="工程名称">
|
<uni-forms-item label="工程名称">
|
||||||
<uni-easyinput type="number" v-model="formData.name" placeholder="请输入工程名称" />
|
<uni-easyinput type="text" v-model="formData.name" placeholder="请输入工程名称" />
|
||||||
</uni-forms-item>
|
</uni-forms-item>
|
||||||
<uni-forms-item label="位置">
|
<uni-forms-item label="位置">
|
||||||
<view style="display:flex;">
|
<!-- <view style="display:flex;">
|
||||||
<uni-easyinput :clearable="false" type="textarea" autoHeight v-model="formData.area"
|
<uni-easyinput :clearable="false" type="textarea" autoHeight v-model="formData.area"
|
||||||
placeholder="请输入位置信息" />
|
placeholder="请输入位置信息" />
|
||||||
<uni-icons type="location" color="#007aff" size="26" class="ml20"
|
<uni-icons type="location" color="#007aff" size="26" class="ml20"
|
||||||
@click="chooseLocation"></uni-icons>
|
@click="chooseLocation"></uni-icons>
|
||||||
</view>
|
</view> -->
|
||||||
|
<uni-data-picker :localdata="localdata" @change="areaChange"> </uni-data-picker>
|
||||||
</uni-forms-item>
|
</uni-forms-item>
|
||||||
<uni-forms-item label="描述">
|
<uni-forms-item label="描述">
|
||||||
<uni-easyinput type="textarea" autoHeight v-model="formData.description"
|
<uni-easyinput type="textarea" autoHeight v-model="formData.description"
|
||||||
@@ -29,35 +30,22 @@
|
|||||||
</Cn-page>
|
</Cn-page>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { addAppProject } from '../../common/api/project'
|
import { addEngineering } from '../../common/api/gc'
|
||||||
// import area from '../../common/js/area.json'
|
import area from '../../common/js/area.json'
|
||||||
export default {
|
export default {
|
||||||
data () {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
localdata: area,
|
||||||
loading: false,
|
loading: false,
|
||||||
formData: {
|
formData: {
|
||||||
area: "",
|
city: "",
|
||||||
files: [],
|
description: "",
|
||||||
description: '',
|
name: "",
|
||||||
projectType: '1',
|
province: "",
|
||||||
name: '',
|
|
||||||
userId: '123456',
|
|
||||||
lat: '2',
|
|
||||||
lng: '3'
|
|
||||||
},
|
},
|
||||||
TypeRange: [
|
|
||||||
{
|
|
||||||
text: '监测',
|
|
||||||
value: '1'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: '用能',
|
|
||||||
value: '2'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad () {
|
onLoad() {
|
||||||
uni.getLocation({
|
uni.getLocation({
|
||||||
type: 'wgs84',
|
type: 'wgs84',
|
||||||
success: function (res) {
|
success: function (res) {
|
||||||
@@ -69,10 +57,15 @@ export default {
|
|||||||
// console.log(area);
|
// console.log(area);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
select (e) {
|
areaChange(e) {
|
||||||
|
console.log(e);
|
||||||
|
this.formData.province = e.detail.value[0].value
|
||||||
|
this.formData.city = e.detail.value[1].value
|
||||||
|
},
|
||||||
|
select(e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
},
|
},
|
||||||
chooseLocation () {
|
chooseLocation() {
|
||||||
|
|
||||||
uni.chooseLocation({
|
uni.chooseLocation({
|
||||||
success: function (res) {
|
success: function (res) {
|
||||||
@@ -84,43 +77,26 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
async submit () {
|
async submit() {
|
||||||
if (!this.formData.name) {
|
if (!this.formData.name) {
|
||||||
this.$util.toast('请输入工程名称')
|
this.$util.toast('请输入工程名称')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!this.formData.projectType) {
|
|
||||||
this.$util.toast('请选择工程类别')
|
if (!this.formData.province) {
|
||||||
return
|
this.$util.toast('请选择区域信息')
|
||||||
}
|
|
||||||
if (!this.formData.area) {
|
|
||||||
this.$util.toast('请输入区域信息')
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!this.formData.description) {
|
if (!this.formData.description) {
|
||||||
this.$util.toast('请输入工程描述')
|
this.$util.toast('请输入工程描述')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!this.formData.files.length) {
|
addEngineering(this.formData).then(res => {
|
||||||
this.$util.toast('请上传拓扑图')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
let arr = []
|
|
||||||
for (let i = 0; i < this.formData.files.length; i++) {
|
|
||||||
let item = this.formData.files[i]
|
|
||||||
arr.push({
|
|
||||||
name: 'files',
|
|
||||||
url: item.url
|
|
||||||
})
|
|
||||||
}
|
|
||||||
let data = JSON.parse(JSON.stringify(this.formData))
|
|
||||||
delete data.files
|
|
||||||
addAppProject(data, arr).then(res => {
|
|
||||||
console.log(res)
|
console.log(res)
|
||||||
this.$util.toast('工程创建成功')
|
this.$util.toast('工程创建成功')
|
||||||
// setTimeout(() => {
|
setTimeout(() => {
|
||||||
// uni.navigateBack({ delta: 1 })
|
uni.navigateBack({ delta: 1 })
|
||||||
// }, 1500);
|
}, 1500);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { pinyin } from 'pinyin-pro';
|
import { pinyin } from 'pinyin-pro';
|
||||||
|
import { queryEngineering } from '@/common/api/gc.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
@@ -133,47 +134,7 @@ export default {
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
gcList: [
|
gcList: [
|
||||||
'南京灿能',
|
|
||||||
'南京灿能',
|
|
||||||
'南京灿能',
|
|
||||||
'南京灿能',
|
|
||||||
'南京灿能',
|
|
||||||
'北京灿能',
|
|
||||||
'北京灿能',
|
|
||||||
'北京灿能',
|
|
||||||
'北京灿能',
|
|
||||||
'北京灿能',
|
|
||||||
'上海灿能',
|
|
||||||
'上海灿能',
|
|
||||||
'上海灿能',
|
|
||||||
'上海灿能',
|
|
||||||
'上海灿能',
|
|
||||||
'上海灿能',
|
|
||||||
'广州灿能',
|
|
||||||
'广州灿能',
|
|
||||||
'广州灿能',
|
|
||||||
'广州灿能',
|
|
||||||
'广州灿能',
|
|
||||||
'深圳灿能',
|
|
||||||
'深圳灿能',
|
|
||||||
'深圳灿能',
|
|
||||||
'深圳灿能',
|
|
||||||
'深圳灿能',
|
|
||||||
'杭州灿能',
|
|
||||||
'杭州灿能',
|
|
||||||
'杭州灿能',
|
|
||||||
'杭州灿能',
|
|
||||||
'杭州灿能',
|
|
||||||
'杭州灿能',
|
|
||||||
'杭州灿能',
|
|
||||||
'苏州灿能',
|
|
||||||
'苏州灿能',
|
|
||||||
'苏州灿能',
|
|
||||||
'苏州灿能',
|
|
||||||
'苏州灿能',
|
|
||||||
'苏州灿能',
|
|
||||||
'苏州灿能',
|
|
||||||
'苏州灿能',
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -202,17 +163,17 @@ export default {
|
|||||||
|
|
||||||
let result = []
|
let result = []
|
||||||
this.gcList.forEach(item => {
|
this.gcList.forEach(item => {
|
||||||
let arr = pinyin(item[0], { toneType: 'none', type: 'array' })
|
let arr = pinyin(item.name[0], { toneType: 'none', type: 'array' })
|
||||||
let letter = arr[0][0].toUpperCase()
|
let letter = arr[0][0].toUpperCase()
|
||||||
console.log(letter);
|
console.log(letter);
|
||||||
let index = result.findIndex(item => item.letter === letter)
|
let index = result.findIndex(item => item.letter === letter)
|
||||||
if (index === -1) {
|
if (index === -1) {
|
||||||
result.push({
|
result.push({
|
||||||
letter,
|
letter,
|
||||||
data: [item]
|
data: [item.name]
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
result[index].data.push(item)
|
result[index].data.push(item.name)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return result
|
return result
|
||||||
@@ -234,7 +195,9 @@ export default {
|
|||||||
showDrawer() {
|
showDrawer() {
|
||||||
this.$refs.showRight.open();
|
this.$refs.showRight.open();
|
||||||
},
|
},
|
||||||
closeDrawer() {
|
closeDrawer(e) {
|
||||||
|
console.log(e);
|
||||||
|
|
||||||
this.$refs.showRight.close();
|
this.$refs.showRight.close();
|
||||||
},
|
},
|
||||||
submitFeedBack() { uni.navigateTo({ url: '/pages/home/feedback' }) },
|
submitFeedBack() { uni.navigateTo({ url: '/pages/home/feedback' }) },
|
||||||
@@ -304,10 +267,16 @@ export default {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
init(){
|
||||||
|
queryEngineering().then(res => {
|
||||||
|
this.gcList = res.data
|
||||||
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.userInfo = uni.getStorageSync('userInfo')
|
this.userInfo = uni.getStorageSync('userInfo')
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
this.init()
|
||||||
// 获取nav高度
|
// 获取nav高度
|
||||||
uni.createSelectorQuery().select('.nav').boundingClientRect((rect) => {
|
uni.createSelectorQuery().select('.nav').boundingClientRect((rect) => {
|
||||||
this.navHeight = rect.height
|
this.navHeight = rect.height
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
<uni-icons type="forward" color="#aaa" size="20"></uni-icons>
|
<uni-icons type="forward" color="#aaa" size="20"></uni-icons>
|
||||||
</view>
|
</view>
|
||||||
<view class="mine-nav" @click="jump('gc')"
|
<view class="mine-nav" @click="jump('gc')"
|
||||||
v-if="userInfo.role == 4 || userInfo.role == 3 || userInfo.role == 2">
|
v-if="userInfo.role == 4 || userInfo.role == 3 ">
|
||||||
<image mode="aspectFill" class="mine-nav-icon" src="/static/project.png" />
|
<image mode="aspectFill" class="mine-nav-icon" src="/static/project.png" />
|
||||||
<view class="mine-nav-label">工程管理</view>
|
<view class="mine-nav-label">工程管理</view>
|
||||||
<uni-icons type="forward" color="#aaa" size="20"></uni-icons>
|
<uni-icons type="forward" color="#aaa" size="20"></uni-icons>
|
||||||
|
|||||||
@@ -1,3 +1,12 @@
|
|||||||
|
## 1.1.2(2023-04-11)
|
||||||
|
- 修复 更改 modelValue 报错的 bug
|
||||||
|
- 修复 v-for 未使用 key 值控制台 warning
|
||||||
|
## 1.1.1(2023-02-21)
|
||||||
|
- 修复代码合并时引发 value 属性为空时不渲染数据的问题
|
||||||
|
## 1.1.0(2023-02-15)
|
||||||
|
- 修复 localdata 不支持动态更新的bug
|
||||||
|
## 1.0.9(2023-02-15)
|
||||||
|
- 修复 localdata 不支持动态更新的bug
|
||||||
## 1.0.8(2022-09-16)
|
## 1.0.8(2022-09-16)
|
||||||
- 可以使用 uni-scss 控制主题色
|
- 可以使用 uni-scss 控制主题色
|
||||||
## 1.0.7(2022-07-06)
|
## 1.0.7(2022-07-06)
|
||||||
|
|||||||
@@ -16,8 +16,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
<text v-else class="selected-area placeholder">{{placeholder}}</text>
|
<text v-else class="selected-area placeholder">{{placeholder}}</text>
|
||||||
<view v-if="clearIcon && !readonly && inputSelected.length" class="icon-clear"
|
<view v-if="clearIcon && !readonly && inputSelected.length" class="icon-clear" @click.stop="clear">
|
||||||
@click.stop="clear">
|
|
||||||
<uni-icons type="clear" color="#c0c4cc" size="24"></uni-icons>
|
<uni-icons type="clear" color="#c0c4cc" size="24"></uni-icons>
|
||||||
</view>
|
</view>
|
||||||
<view class="arrow-area" v-if="(!clearIcon || !inputSelected.length) && !readonly ">
|
<view class="arrow-area" v-if="(!clearIcon || !inputSelected.length) && !readonly ">
|
||||||
@@ -40,8 +39,8 @@
|
|||||||
</view>
|
</view>
|
||||||
<data-picker-view class="picker-view" ref="pickerView" v-model="dataValue" :localdata="localdata"
|
<data-picker-view class="picker-view" ref="pickerView" v-model="dataValue" :localdata="localdata"
|
||||||
:preload="preload" :collection="collection" :field="field" :orderby="orderby" :where="where"
|
:preload="preload" :collection="collection" :field="field" :orderby="orderby" :where="where"
|
||||||
:step-searh="stepSearh" :self-field="selfField" :parent-field="parentField" :managed-mode="true"
|
:step-searh="stepSearh" :self-field="selfField" :parent-field="parentField" :managed-mode="true" :map="map"
|
||||||
:map="map" :ellipsis="ellipsis" @change="onchange" @datachange="ondatachange" @nodeclick="onnodeclick">
|
:ellipsis="ellipsis" @change="onchange" @datachange="ondatachange" @nodeclick="onnodeclick">
|
||||||
</data-picker-view>
|
</data-picker-view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -76,7 +75,7 @@
|
|||||||
*/
|
*/
|
||||||
export default {
|
export default {
|
||||||
name: 'UniDataPicker',
|
name: 'UniDataPicker',
|
||||||
emits: ['popupopened', 'popupclosed', 'nodeclick', 'input', 'change', 'update:modelValue'],
|
emits: ['popupopened', 'popupclosed', 'nodeclick', 'input', 'change', 'update:modelValue','inputclick'],
|
||||||
mixins: [dataPicker],
|
mixins: [dataPicker],
|
||||||
components: {
|
components: {
|
||||||
DataPickerView
|
DataPickerView
|
||||||
@@ -128,58 +127,49 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.form = this.getForm('uniForms')
|
|
||||||
this.formItem = this.getForm('uniFormsItem')
|
|
||||||
if (this.formItem) {
|
|
||||||
if (this.formItem.name) {
|
|
||||||
this.rename = this.formItem.name
|
|
||||||
this.form.inputChildrens.push(this)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.load()
|
this.load();
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
localdata: {
|
||||||
|
handler() {
|
||||||
|
this.load()
|
||||||
|
},
|
||||||
|
deep: true
|
||||||
|
},
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
clear() {
|
clear() {
|
||||||
this.inputSelected.splice(0)
|
this._dispatchEvent([]);
|
||||||
this._dispatchEvent([])
|
|
||||||
},
|
},
|
||||||
onPropsChange() {
|
onPropsChange() {
|
||||||
this._treeData = []
|
this._treeData = [];
|
||||||
this.selectedIndex = 0
|
this.selectedIndex = 0;
|
||||||
this.load()
|
|
||||||
|
this.load();
|
||||||
},
|
},
|
||||||
load() {
|
load() {
|
||||||
if (this.readonly) {
|
if (this.readonly) {
|
||||||
this._processReadonly(this.localdata, this.dataValue)
|
this._processReadonly(this.localdata, this.dataValue);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isLocaldata) {
|
// 回显本地数据
|
||||||
this.loadData()
|
if (this.isLocalData) {
|
||||||
this.inputSelected = this.selected.slice(0)
|
this.loadData();
|
||||||
} else if (!this.parentField && !this.selfField && this.hasValue) {
|
this.inputSelected = this.selected.slice(0);
|
||||||
this.getNodeData(() => {
|
} else if (this.isCloudDataList || this.isCloudDataTree) { // 回显 Cloud 数据
|
||||||
this.inputSelected = this.selected.slice(0)
|
this.loading = true;
|
||||||
})
|
this.getCloudDataValue().then((res) => {
|
||||||
} else if (this.hasValue) {
|
this.loading = false;
|
||||||
this.getTreePath(() => {
|
this.inputSelected = res;
|
||||||
this.inputSelected = this.selected.slice(0)
|
}).catch((err) => {
|
||||||
|
this.loading = false;
|
||||||
|
this.errorMessage = err;
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getForm(name = 'uniForms') {
|
|
||||||
let parent = this.$parent;
|
|
||||||
let parentName = parent.$options.name;
|
|
||||||
while (parentName !== name) {
|
|
||||||
parent = parent.$parent;
|
|
||||||
if (!parent) return false;
|
|
||||||
parentName = parent.$options.name;
|
|
||||||
}
|
|
||||||
return parent;
|
|
||||||
},
|
|
||||||
show() {
|
show() {
|
||||||
this.isOpened = true
|
this.isOpened = true
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -197,6 +187,7 @@
|
|||||||
},
|
},
|
||||||
handleInput() {
|
handleInput() {
|
||||||
if (this.readonly) {
|
if (this.readonly) {
|
||||||
|
this.$emit('inputclick')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.show()
|
this.show()
|
||||||
@@ -294,7 +285,7 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style >
|
<style>
|
||||||
.uni-data-tree {
|
.uni-data-tree {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
position: relative;
|
position: relative;
|
||||||
@@ -413,7 +404,12 @@
|
|||||||
.uni-data-tree-dialog {
|
.uni-data-tree-dialog {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
left: 0;
|
left: 0;
|
||||||
|
/* #ifndef APP-NVUE */
|
||||||
top: 20%;
|
top: 20%;
|
||||||
|
/* #endif */
|
||||||
|
/* #ifdef APP-NVUE */
|
||||||
|
top: 200px;
|
||||||
|
/* #endif */
|
||||||
right: 0;
|
right: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
background-color: #FFFFFF;
|
background-color: #FFFFFF;
|
||||||
@@ -550,5 +546,6 @@
|
|||||||
border-top-width: 0;
|
border-top-width: 0;
|
||||||
border-bottom-color: #fff;
|
border-bottom-color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* #endif */
|
/* #endif */
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ export default {
|
|||||||
},
|
},
|
||||||
pageSize: {
|
pageSize: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 20
|
default: 500
|
||||||
},
|
},
|
||||||
getcount: {
|
getcount: {
|
||||||
type: [Boolean, String],
|
type: [Boolean, String],
|
||||||
@@ -94,7 +94,7 @@ export default {
|
|||||||
},
|
},
|
||||||
map: {
|
map: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default() {
|
default () {
|
||||||
return {
|
return {
|
||||||
text: "text",
|
text: "text",
|
||||||
value: "value"
|
value: "value"
|
||||||
@@ -122,19 +122,22 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
isLocaldata() {
|
isLocalData() {
|
||||||
return !this.collection.length
|
return !this.collection.length;
|
||||||
},
|
},
|
||||||
postField() {
|
isCloudData() {
|
||||||
let fields = [this.field];
|
return this.collection.length > 0;
|
||||||
if (this.parentField) {
|
},
|
||||||
fields.push(`${this.parentField} as parent_value`);
|
isCloudDataList() {
|
||||||
}
|
return (this.isCloudData && (!this.parentField && !this.selfField));
|
||||||
return fields.join(',');
|
},
|
||||||
|
isCloudDataTree() {
|
||||||
|
return (this.isCloudData && this.parentField && this.selfField);
|
||||||
},
|
},
|
||||||
dataValue() {
|
dataValue() {
|
||||||
let isModelValue = Array.isArray(this.modelValue) ? (this.modelValue.length > 0) : (this.modelValue !== null || this.modelValue !== undefined)
|
let isModelValue = Array.isArray(this.modelValue) ? (this.modelValue.length > 0) : (this.modelValue !== null ||
|
||||||
return isModelValue ? this.modelValue : this.value
|
this.modelValue !== undefined);
|
||||||
|
return isModelValue ? this.modelValue : this.value;
|
||||||
},
|
},
|
||||||
hasValue() {
|
hasValue() {
|
||||||
if (typeof this.dataValue === 'number') {
|
if (typeof this.dataValue === 'number') {
|
||||||
@@ -183,8 +186,169 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onPropsChange() {
|
onPropsChange() {
|
||||||
this._treeData = []
|
this._treeData = [];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 填充 pickview 数据
|
||||||
|
async loadData() {
|
||||||
|
if (this.isLocalData) {
|
||||||
|
this.loadLocalData();
|
||||||
|
} else if (this.isCloudDataList) {
|
||||||
|
this.loadCloudDataList();
|
||||||
|
} else if (this.isCloudDataTree) {
|
||||||
|
this.loadCloudDataTree();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 加载本地数据
|
||||||
|
async loadLocalData() {
|
||||||
|
this._treeData = [];
|
||||||
|
this._extractTree(this.localdata, this._treeData);
|
||||||
|
|
||||||
|
let inputValue = this.dataValue;
|
||||||
|
if (inputValue === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(inputValue)) {
|
||||||
|
inputValue = inputValue[inputValue.length - 1];
|
||||||
|
if (typeof inputValue === 'object' && inputValue[this.map.value]) {
|
||||||
|
inputValue = inputValue[this.map.value];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.selected = this._findNodePath(inputValue, this.localdata);
|
||||||
|
},
|
||||||
|
|
||||||
|
// 加载 Cloud 数据 (单列)
|
||||||
|
async loadCloudDataList() {
|
||||||
|
if (this.loading) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.loading = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
let response = await this.getCommand();
|
||||||
|
let responseData = response.result.data;
|
||||||
|
|
||||||
|
this._treeData = responseData;
|
||||||
|
|
||||||
|
this._updateBindData();
|
||||||
|
this._updateSelected();
|
||||||
|
|
||||||
|
this.onDataChange();
|
||||||
|
} catch (e) {
|
||||||
|
this.errorMessage = e;
|
||||||
|
} finally {
|
||||||
|
this.loading = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 加载 Cloud 数据 (树形)
|
||||||
|
async loadCloudDataTree() {
|
||||||
|
if (this.loading) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.loading = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
let commandOptions = {
|
||||||
|
field: this._cloudDataPostField(),
|
||||||
|
where: this._cloudDataTreeWhere()
|
||||||
|
};
|
||||||
|
if (this.gettree) {
|
||||||
|
commandOptions.startwith = `${this.selfField}=='${this.dataValue}'`;
|
||||||
|
}
|
||||||
|
|
||||||
|
let response = await this.getCommand(commandOptions);
|
||||||
|
let responseData = response.result.data;
|
||||||
|
|
||||||
|
this._treeData = responseData;
|
||||||
|
this._updateBindData();
|
||||||
|
this._updateSelected();
|
||||||
|
|
||||||
|
this.onDataChange();
|
||||||
|
} catch (e) {
|
||||||
|
this.errorMessage = e;
|
||||||
|
} finally {
|
||||||
|
this.loading = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 加载 Cloud 数据 (节点)
|
||||||
|
async loadCloudDataNode(callback) {
|
||||||
|
if (this.loading) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.loading = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
let commandOptions = {
|
||||||
|
field: this._cloudDataPostField(),
|
||||||
|
where: this._cloudDataNodeWhere()
|
||||||
|
};
|
||||||
|
|
||||||
|
let response = await this.getCommand(commandOptions);
|
||||||
|
let responseData = response.result.data;
|
||||||
|
|
||||||
|
callback(responseData);
|
||||||
|
} catch (e) {
|
||||||
|
this.errorMessage = e;
|
||||||
|
} finally {
|
||||||
|
this.loading = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 回显 Cloud 数据
|
||||||
|
getCloudDataValue() {
|
||||||
|
if (this.isCloudDataList) {
|
||||||
|
return this.getCloudDataListValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.isCloudDataTree) {
|
||||||
|
return this.getCloudDataTreeValue();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 回显 Cloud 数据 (单列)
|
||||||
|
getCloudDataListValue() {
|
||||||
|
// 根据 field's as value标识匹配 where 条件
|
||||||
|
let where = [];
|
||||||
|
let whereField = this._getForeignKeyByField();
|
||||||
|
if (whereField) {
|
||||||
|
where.push(`${whereField} == '${this.dataValue}'`)
|
||||||
|
}
|
||||||
|
|
||||||
|
where = where.join(' || ');
|
||||||
|
|
||||||
|
if (this.where) {
|
||||||
|
where = `(${this.where}) && (${where})`
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.getCommand({
|
||||||
|
field: this._cloudDataPostField(),
|
||||||
|
where
|
||||||
|
}).then((res) => {
|
||||||
|
this.selected = res.result.data;
|
||||||
|
return res.result.data;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
// 回显 Cloud 数据 (树形)
|
||||||
|
getCloudDataTreeValue() {
|
||||||
|
return this.getCommand({
|
||||||
|
field: this._cloudDataPostField(),
|
||||||
|
getTreePath: {
|
||||||
|
startWith: `${this.selfField}=='${this.dataValue}'`
|
||||||
|
}
|
||||||
|
}).then((res) => {
|
||||||
|
let treePath = [];
|
||||||
|
this._extractTreePath(res.result.data, treePath);
|
||||||
|
this.selected = treePath;
|
||||||
|
return treePath;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
getCommand(options = {}) {
|
getCommand(options = {}) {
|
||||||
/* eslint-disable no-undef */
|
/* eslint-disable no-undef */
|
||||||
let db = uniCloud.database(this.spaceInfo)
|
let db = uniCloud.database(this.spaceInfo)
|
||||||
@@ -229,125 +393,16 @@ export default {
|
|||||||
|
|
||||||
return db
|
return db
|
||||||
},
|
},
|
||||||
getNodeData(callback) {
|
|
||||||
if (this.loading) {
|
_cloudDataPostField() {
|
||||||
return
|
let fields = [this.field];
|
||||||
|
if (this.parentField) {
|
||||||
|
fields.push(`${this.parentField} as parent_value`);
|
||||||
}
|
}
|
||||||
this.loading = true
|
return fields.join(',');
|
||||||
this.getCommand({
|
|
||||||
field: this.postField,
|
|
||||||
where: this._pathWhere()
|
|
||||||
}).then((res) => {
|
|
||||||
this.loading = false
|
|
||||||
this.selected = res.result.data
|
|
||||||
callback && callback()
|
|
||||||
}).catch((err) => {
|
|
||||||
this.loading = false
|
|
||||||
this.errorMessage = err
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
getTreePath(callback) {
|
|
||||||
if (this.loading) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.loading = true
|
|
||||||
|
|
||||||
this.getCommand({
|
_cloudDataTreeWhere() {
|
||||||
field: this.postField,
|
|
||||||
getTreePath: {
|
|
||||||
startWith: `${this.selfField}=='${this.dataValue}'`
|
|
||||||
}
|
|
||||||
}).then((res) => {
|
|
||||||
this.loading = false
|
|
||||||
let treePath = []
|
|
||||||
this._extractTreePath(res.result.data, treePath)
|
|
||||||
this.selected = treePath
|
|
||||||
callback && callback()
|
|
||||||
}).catch((err) => {
|
|
||||||
this.loading = false
|
|
||||||
this.errorMessage = err
|
|
||||||
})
|
|
||||||
},
|
|
||||||
loadData() {
|
|
||||||
if (this.isLocaldata) {
|
|
||||||
this._processLocalData()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.dataValue != null) {
|
|
||||||
this._loadNodeData((data) => {
|
|
||||||
this._treeData = data
|
|
||||||
this._updateBindData()
|
|
||||||
this._updateSelected()
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.stepSearh) {
|
|
||||||
this._loadNodeData((data) => {
|
|
||||||
this._treeData = data
|
|
||||||
this._updateBindData()
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
this._loadAllData((data) => {
|
|
||||||
this._treeData = []
|
|
||||||
this._extractTree(data, this._treeData, null)
|
|
||||||
this._updateBindData()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
_loadAllData(callback) {
|
|
||||||
if (this.loading) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.loading = true
|
|
||||||
|
|
||||||
this.getCommand({
|
|
||||||
field: this.postField,
|
|
||||||
gettree: true,
|
|
||||||
startwith: `${this.selfField}=='${this.dataValue}'`
|
|
||||||
}).then((res) => {
|
|
||||||
this.loading = false
|
|
||||||
callback(res.result.data)
|
|
||||||
this.onDataChange()
|
|
||||||
}).catch((err) => {
|
|
||||||
this.loading = false
|
|
||||||
this.errorMessage = err
|
|
||||||
})
|
|
||||||
},
|
|
||||||
_loadNodeData(callback, pw) {
|
|
||||||
if (this.loading) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.loading = true
|
|
||||||
|
|
||||||
this.getCommand({
|
|
||||||
field: this.postField,
|
|
||||||
where: pw || this._postWhere(),
|
|
||||||
pageSize: 500
|
|
||||||
}).then((res) => {
|
|
||||||
this.loading = false
|
|
||||||
callback(res.result.data)
|
|
||||||
this.onDataChange()
|
|
||||||
}).catch((err) => {
|
|
||||||
this.loading = false
|
|
||||||
this.errorMessage = err
|
|
||||||
})
|
|
||||||
},
|
|
||||||
_pathWhere() {
|
|
||||||
let result = []
|
|
||||||
let where_field = this._getParentNameByField();
|
|
||||||
if (where_field) {
|
|
||||||
result.push(`${where_field} == '${this.dataValue}'`)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.where) {
|
|
||||||
return `(${this.where}) && (${result.join(' || ')})`
|
|
||||||
}
|
|
||||||
|
|
||||||
return result.join(' || ')
|
|
||||||
},
|
|
||||||
_postWhere() {
|
|
||||||
let result = []
|
let result = []
|
||||||
let selected = this.selected
|
let selected = this.selected
|
||||||
let parentField = this.parentField
|
let parentField = this.parentField
|
||||||
@@ -364,17 +419,35 @@ export default {
|
|||||||
if (this.where) {
|
if (this.where) {
|
||||||
where.push(`(${this.where})`)
|
where.push(`(${this.where})`)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.length) {
|
if (result.length) {
|
||||||
where.push(`(${result.join(' || ')})`)
|
where.push(`(${result.join(' || ')})`)
|
||||||
}
|
}
|
||||||
|
|
||||||
return where.join(' && ')
|
return where.join(' && ')
|
||||||
},
|
},
|
||||||
_nodeWhere() {
|
|
||||||
let result = []
|
_cloudDataNodeWhere() {
|
||||||
let selected = this.selected
|
let where = []
|
||||||
|
let selected = this.selected;
|
||||||
if (selected.length) {
|
if (selected.length) {
|
||||||
result.push(`${this.parentField} == '${selected[selected.length - 1].value}'`)
|
where.push(`${this.parentField} == '${selected[selected.length - 1].value}'`);
|
||||||
|
}
|
||||||
|
|
||||||
|
where = where.join(' || ');
|
||||||
|
|
||||||
|
if (this.where) {
|
||||||
|
return `(${this.where}) && (${where})`
|
||||||
|
}
|
||||||
|
|
||||||
|
return where
|
||||||
|
},
|
||||||
|
|
||||||
|
_getWhereByForeignKey() {
|
||||||
|
let result = []
|
||||||
|
let whereField = this._getForeignKeyByField();
|
||||||
|
if (whereField) {
|
||||||
|
result.push(`${whereField} == '${this.dataValue}'`)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.where) {
|
if (this.where) {
|
||||||
@@ -383,41 +456,23 @@ export default {
|
|||||||
|
|
||||||
return result.join(' || ')
|
return result.join(' || ')
|
||||||
},
|
},
|
||||||
_getParentNameByField() {
|
|
||||||
const fields = this.field.split(',');
|
_getForeignKeyByField() {
|
||||||
let where_field = null;
|
let fields = this.field.split(',');
|
||||||
|
let whereField = null;
|
||||||
for (let i = 0; i < fields.length; i++) {
|
for (let i = 0; i < fields.length; i++) {
|
||||||
const items = fields[i].split('as');
|
const items = fields[i].split('as');
|
||||||
if (items.length < 2) {
|
if (items.length < 2) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (items[1].trim() === 'value') {
|
if (items[1].trim() === 'value') {
|
||||||
where_field = items[0].trim();
|
whereField = items[0].trim();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return where_field
|
return whereField;
|
||||||
},
|
|
||||||
_isTreeView() {
|
|
||||||
return (this.parentField && this.selfField)
|
|
||||||
},
|
|
||||||
_updateSelected() {
|
|
||||||
var dl = this.dataList
|
|
||||||
var sl = this.selected
|
|
||||||
let textField = this.map.text
|
|
||||||
let valueField = this.map.value
|
|
||||||
for (var i = 0; i < sl.length; i++) {
|
|
||||||
var value = sl[i].value
|
|
||||||
var dl2 = dl[i]
|
|
||||||
for (var j = 0; j < dl2.length; j++) {
|
|
||||||
var item2 = dl2[j]
|
|
||||||
if (item2[valueField] === value) {
|
|
||||||
sl[i].text = item2[textField]
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_updateBindData(node) {
|
_updateBindData(node) {
|
||||||
const {
|
const {
|
||||||
dataList,
|
dataList,
|
||||||
@@ -445,6 +500,25 @@ export default {
|
|||||||
hasNodes
|
hasNodes
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_updateSelected() {
|
||||||
|
let dl = this.dataList
|
||||||
|
let sl = this.selected
|
||||||
|
let textField = this.map.text
|
||||||
|
let valueField = this.map.value
|
||||||
|
for (let i = 0; i < sl.length; i++) {
|
||||||
|
let value = sl[i].value
|
||||||
|
let dl2 = dl[i]
|
||||||
|
for (let j = 0; j < dl2.length; j++) {
|
||||||
|
let item2 = dl2[j]
|
||||||
|
if (item2[valueField] === value) {
|
||||||
|
sl[i].text = item2[textField]
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
_filterData(data, paths) {
|
_filterData(data, paths) {
|
||||||
let dataList = []
|
let dataList = []
|
||||||
let hasNodes = true
|
let hasNodes = true
|
||||||
@@ -453,8 +527,8 @@ export default {
|
|||||||
return (item.parent_value === null || item.parent_value === undefined || item.parent_value === '')
|
return (item.parent_value === null || item.parent_value === undefined || item.parent_value === '')
|
||||||
}))
|
}))
|
||||||
for (let i = 0; i < paths.length; i++) {
|
for (let i = 0; i < paths.length; i++) {
|
||||||
var value = paths[i].value
|
let value = paths[i].value
|
||||||
var nodes = data.filter((item) => {
|
let nodes = data.filter((item) => {
|
||||||
return item.parent_value === value
|
return item.parent_value === value
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -470,6 +544,7 @@ export default {
|
|||||||
hasNodes
|
hasNodes
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_extractTree(nodes, result, parent_value) {
|
_extractTree(nodes, result, parent_value) {
|
||||||
let list = result || []
|
let list = result || []
|
||||||
let valueField = this.map.value
|
let valueField = this.map.value
|
||||||
@@ -493,6 +568,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_extractTreePath(nodes, result) {
|
_extractTreePath(nodes, result) {
|
||||||
let list = result || []
|
let list = result || []
|
||||||
for (let i = 0; i < nodes.length; i++) {
|
for (let i = 0; i < nodes.length; i++) {
|
||||||
@@ -512,6 +588,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_findNodePath(key, nodes, path = []) {
|
_findNodePath(key, nodes, path = []) {
|
||||||
let textField = this.map.text
|
let textField = this.map.text
|
||||||
let valueField = this.map.value
|
let valueField = this.map.value
|
||||||
@@ -540,24 +617,6 @@ export default {
|
|||||||
path.pop()
|
path.pop()
|
||||||
}
|
}
|
||||||
return []
|
return []
|
||||||
},
|
|
||||||
_processLocalData() {
|
|
||||||
this._treeData = []
|
|
||||||
this._extractTree(this.localdata, this._treeData)
|
|
||||||
|
|
||||||
var inputValue = this.dataValue
|
|
||||||
if (inputValue === undefined) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Array.isArray(inputValue)) {
|
|
||||||
inputValue = inputValue[inputValue.length - 1]
|
|
||||||
if (typeof inputValue === 'object' && inputValue[this.map.value]) {
|
|
||||||
inputValue = inputValue[this.map.value]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.selected = this._findNodePath(inputValue, this.localdata)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +1,28 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="uni-data-pickerview">
|
<view class="uni-data-pickerview">
|
||||||
<scroll-view class="selected-area" scroll-x="true" scroll-y="false" :show-scrollbar="false">
|
<scroll-view v-if="!isCloudDataList" class="selected-area" scroll-x="true">
|
||||||
<view class="selected-list">
|
<view class="selected-list">
|
||||||
<template v-for="(item,index) in selected">
|
<view
|
||||||
<view class="selected-item"
|
class="selected-item"
|
||||||
:class="{'selected-item-active':index==selectedIndex, 'selected-item-text-overflow': ellipsis}"
|
v-for="(item,index) in selected"
|
||||||
v-if="item.text" @click="handleSelect(index)">
|
:key="index"
|
||||||
<text class="">{{item.text}}</text>
|
:class="{
|
||||||
|
'selected-item-active':index == selectedIndex
|
||||||
|
}"
|
||||||
|
@click="handleSelect(index)"
|
||||||
|
>
|
||||||
|
<text>{{item.text || ''}}</text>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
<view class="tab-c">
|
<view class="tab-c">
|
||||||
<template v-for="(child, i) in dataList" >
|
<scroll-view class="list" :scroll-y="true">
|
||||||
<scroll-view class="list" :key="i" v-if="i==selectedIndex" :scroll-y="true">
|
<view class="item" :class="{'is-disabled': !!item.disable}" v-for="(item, j) in dataList[selectedIndex]" :key="j"
|
||||||
<view class="item" :class="{'is-disabled': !!item.disable}" v-for="(item, j) in child"
|
@click="handleNodeClick(item, selectedIndex, j)">
|
||||||
@click="handleNodeClick(item, i, j)">
|
<text class="item-text">{{item[map.text]}}</text>
|
||||||
<text class="item-text item-text-overflow">{{item[map.text]}}</text>
|
<view class="check" v-if="selected.length > selectedIndex && item[map.value] == selected[selectedIndex].value"></view>
|
||||||
<view class="check" v-if="selected.length > i && item[map.value] == selected[i].value"></view>
|
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
</template>
|
|
||||||
|
|
||||||
<view class="loading-cover" v-if="loading">
|
<view class="loading-cover" v-if="loading">
|
||||||
<uni-load-more class="load-more" :contentText="loadMore" status="loading"></uni-load-more>
|
<uni-load-more class="load-more" :contentText="loadMore" status="loading"></uni-load-more>
|
||||||
@@ -64,43 +66,33 @@
|
|||||||
default: true
|
default: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
|
||||||
return {}
|
|
||||||
},
|
|
||||||
created() {
|
created() {
|
||||||
if (this.managedMode) {
|
if (!this.managedMode) {
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.load()
|
this.loadData();
|
||||||
})
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onPropsChange() {
|
onPropsChange() {
|
||||||
this._treeData = []
|
this._treeData = [];
|
||||||
this.selectedIndex = 0
|
this.selectedIndex = 0;
|
||||||
this.load()
|
this.$nextTick(() => {
|
||||||
},
|
this.loadData();
|
||||||
load() {
|
|
||||||
if (this.isLocaldata) {
|
|
||||||
this.loadData()
|
|
||||||
} else if (this.dataValue.length) {
|
|
||||||
this.getTreePath((res) => {
|
|
||||||
this.loadData()
|
|
||||||
})
|
})
|
||||||
}
|
|
||||||
},
|
},
|
||||||
handleSelect(index) {
|
handleSelect(index) {
|
||||||
this.selectedIndex = index
|
this.selectedIndex = index;
|
||||||
},
|
},
|
||||||
handleNodeClick(item, i, j) {
|
handleNodeClick(item, i, j) {
|
||||||
if (item.disable) {
|
if (item.disable) {
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
const node = this.dataList[i][j]
|
|
||||||
const text = node[this.map.text]
|
const node = this.dataList[i][j];
|
||||||
const value = node[this.map.value]
|
const text = node[this.map.text];
|
||||||
|
const value = node[this.map.value];
|
||||||
|
|
||||||
if (i < this.selected.length - 1) {
|
if (i < this.selected.length - 1) {
|
||||||
this.selected.splice(i, this.selected.length - i)
|
this.selected.splice(i, this.selected.length - i)
|
||||||
this.selected.push({
|
this.selected.push({
|
||||||
@@ -124,18 +116,16 @@
|
|||||||
hasNodes
|
hasNodes
|
||||||
} = this._updateBindData()
|
} = this._updateBindData()
|
||||||
|
|
||||||
if (!this._isTreeView() && !hasNodes) {
|
// 本地数据
|
||||||
|
if (this.isLocalData) {
|
||||||
|
this.onSelectedChange(node, (!hasNodes || isleaf))
|
||||||
|
} else if (this.isCloudDataList) { // Cloud 数据 (单列)
|
||||||
this.onSelectedChange(node, true)
|
this.onSelectedChange(node, true)
|
||||||
return
|
} else if (this.isCloudDataTree) { // Cloud 数据 (树形)
|
||||||
}
|
if (isleaf) {
|
||||||
|
this.onSelectedChange(node, node.isleaf)
|
||||||
if (this.isLocaldata && (!hasNodes || isleaf)) {
|
} else if (!hasNodes) { // 请求一次服务器以确定是否为叶子节点
|
||||||
this.onSelectedChange(node, true)
|
this.loadCloudDataNode((data) => {
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isleaf && !hasNodes) {
|
|
||||||
this._loadNodeData((data) => {
|
|
||||||
if (!data.length) {
|
if (!data.length) {
|
||||||
node.isleaf = true
|
node.isleaf = true
|
||||||
} else {
|
} else {
|
||||||
@@ -143,11 +133,9 @@
|
|||||||
this._updateBindData(node)
|
this._updateBindData(node)
|
||||||
}
|
}
|
||||||
this.onSelectedChange(node, node.isleaf)
|
this.onSelectedChange(node, node.isleaf)
|
||||||
}, this._nodeWhere())
|
})
|
||||||
return
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.onSelectedChange(node, false)
|
|
||||||
},
|
},
|
||||||
updateData(data) {
|
updateData(data) {
|
||||||
this._treeData = data.treeData
|
this._treeData = data.treeData
|
||||||
@@ -160,7 +148,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onDataChange() {
|
onDataChange() {
|
||||||
this.$emit('datachange')
|
this.$emit('datachange');
|
||||||
},
|
},
|
||||||
onSelectedChange(node, isleaf) {
|
onSelectedChange(node, isleaf) {
|
||||||
if (isleaf) {
|
if (isleaf) {
|
||||||
@@ -177,6 +165,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
$uni-primary: #007aff !default;
|
$uni-primary: #007aff !default;
|
||||||
|
|
||||||
@@ -231,15 +220,14 @@
|
|||||||
.selected-area {
|
.selected-area {
|
||||||
width: 750rpx;
|
width: 750rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* #endif */
|
/* #endif */
|
||||||
|
|
||||||
.selected-list {
|
.selected-list {
|
||||||
/* #ifndef APP-NVUE */
|
/* #ifndef APP-NVUE */
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-wrap: nowrap;
|
||||||
/* #endif */
|
/* #endif */
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
flex-wrap: nowrap;
|
|
||||||
padding: 0 5px;
|
padding: 0 5px;
|
||||||
border-bottom: 1px solid #f8f8f8;
|
border-bottom: 1px solid #f8f8f8;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"id": "uni-data-picker",
|
"id": "uni-data-picker",
|
||||||
"displayName": "uni-data-picker 数据驱动的picker选择器",
|
"displayName": "uni-data-picker 数据驱动的picker选择器",
|
||||||
"version": "1.0.8",
|
"version": "1.1.2",
|
||||||
"description": "单列、多列级联选择器,常用于省市区城市选择、公司部门选择、多级分类等场景",
|
"description": "单列、多列级联选择器,常用于省市区城市选择、公司部门选择、多级分类等场景",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"uni-ui",
|
"uni-ui",
|
||||||
|
|||||||
Reference in New Issue
Block a user