|
|
@@ -40,37 +40,51 @@
|
|
|
</van-cell>
|
|
|
</van-cell-group>
|
|
|
<!--多选 -->
|
|
|
- <van-checkbox-group ref="checkboxGroup" v-model="checkbox" :max="multiple?0:1">
|
|
|
- <van-cell-group>
|
|
|
- <van-cell
|
|
|
- v-for="(data,index) in dataList"
|
|
|
- :key="data[valueKey]+index"
|
|
|
- clickable
|
|
|
- @click="toggle(data,index)"
|
|
|
- >
|
|
|
- <div slot="title">
|
|
|
- <van-checkbox
|
|
|
- ref="checkboxes"
|
|
|
- :name="data[valueKey]"
|
|
|
- >
|
|
|
- <field-formatter
|
|
|
- :label-key="labelKey"
|
|
|
- :data="data"
|
|
|
- :template-fields="templateFields"
|
|
|
- />
|
|
|
- </van-checkbox>
|
|
|
- </div>
|
|
|
- <span
|
|
|
- v-if="hasChild(data)"
|
|
|
- slot="right-icon"
|
|
|
+ <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="loadData">
|
|
|
+ <van-checkbox-group ref="checkboxGroup" v-model="checkbox" :max="multiple?0:1">
|
|
|
+ <van-cell-group>
|
|
|
+ <van-cell
|
|
|
+ v-for="(data,index) in dataList"
|
|
|
+ :key="data[valueKey]+index"
|
|
|
+ clickable
|
|
|
@click="toggle(data,index)"
|
|
|
>
|
|
|
- <span class="van-cell__right-icon" />
|
|
|
- <van-icon name="arrow " class="van-cell__right-icon" />
|
|
|
- </span>
|
|
|
- </van-cell>
|
|
|
- </van-cell-group>
|
|
|
- </van-checkbox-group>
|
|
|
+ <div slot="title">
|
|
|
+ <van-checkbox
|
|
|
+ ref="checkboxes"
|
|
|
+ :name="data[valueKey]"
|
|
|
+ >
|
|
|
+ <!-- <field-formatter
|
|
|
+ :label-key="labelKey"
|
|
|
+ :data="data"
|
|
|
+ :template-fields="templateFields"
|
|
|
+ /> -->
|
|
|
+ <div>
|
|
|
+ <div v-for="(item, i) in data" :key="i">
|
|
|
+ <span v-if="item.label">{{ item.label }}</span>
|
|
|
+ <span v-if="item.label">:</span>
|
|
|
+ <span v-if="item.val">{{ item.val }}</span>
|
|
|
+ <tree-popup
|
|
|
+ :visible="visible"
|
|
|
+ :selectedData="selectedData"
|
|
|
+ @close="visible => treeVisible = visible"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </van-checkbox>
|
|
|
+ </div>
|
|
|
+ <span
|
|
|
+ v-if="hasChild(data)"
|
|
|
+ slot="right-icon"
|
|
|
+ @click="toggle(data,index)"
|
|
|
+ >
|
|
|
+ <span class="van-cell__right-icon" />
|
|
|
+ <van-icon name="arrow " class="van-cell__right-icon" />
|
|
|
+ </span>
|
|
|
+ </van-cell>
|
|
|
+ </van-cell-group>
|
|
|
+ </van-checkbox-group>
|
|
|
+ </van-list>
|
|
|
</van-popup>
|
|
|
|
|
|
<!--点击明细-查看选中的 -->
|
|
|
@@ -127,18 +141,20 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { queryDataByKey, queryDataById } from '@/api/platform/data/dataTemplate'
|
|
|
+import { queryDataByKey, queryDataById, getByKey } from '@/api/platform/data/dataTemplate'
|
|
|
import { remoteRequest } from '@/utils/remote'
|
|
|
import TreeUtils from '@/utils/tree'
|
|
|
import ActionUtils from '@/utils/action'
|
|
|
import i18n from '@/utils/i18n' // Internationalization 国际化
|
|
|
import FieldFormatter from './field-formatter'
|
|
|
import IbpsPickerToolbar from '@/components/ibps-picker-toolbar'
|
|
|
+import TreePopup from '../../org/selector/popup-tree/index.vue'
|
|
|
|
|
|
export default {
|
|
|
components: {
|
|
|
IbpsPickerToolbar,
|
|
|
- FieldFormatter
|
|
|
+ FieldFormatter,
|
|
|
+ TreePopup
|
|
|
},
|
|
|
props: {
|
|
|
visible: Boolean,
|
|
|
@@ -150,6 +166,7 @@ export default {
|
|
|
leftText: String,
|
|
|
searchPlaceholder: String,
|
|
|
isTree: Boolean,
|
|
|
+ datat: Object,
|
|
|
idKey: { // 唯一键
|
|
|
type: String,
|
|
|
default: 'id_'
|
|
|
@@ -184,9 +201,12 @@ export default {
|
|
|
displayColumns: [],
|
|
|
|
|
|
checkedValue: [],
|
|
|
-
|
|
|
+ dataTem: {},
|
|
|
showDialogPopup: false,
|
|
|
- showDetailPopup: false
|
|
|
+ showDetailPopup: false,
|
|
|
+ page: 1,
|
|
|
+ loading: true,
|
|
|
+ finished: false
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
@@ -234,6 +254,7 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
initData() {
|
|
|
+ console.log(this.datat, 'dataTemplate')
|
|
|
const data = this.value
|
|
|
this.checkedValue = []
|
|
|
this.checkbox = []
|
|
|
@@ -268,6 +289,7 @@ export default {
|
|
|
remoteRequest('dataTemplate', params, () => {
|
|
|
return this.getRemoteDataTemplateByIdFunc(params)
|
|
|
}).then(responseData => {
|
|
|
+ console.log(responseData, 'responseData')
|
|
|
if (this.$utils.isNotEmpty(responseData) && this.$utils.isNotEmpty(responseData.data)) {
|
|
|
const data = responseData.data[0] || {}
|
|
|
let key = id
|
|
|
@@ -307,30 +329,65 @@ export default {
|
|
|
if (!this.isTre) {
|
|
|
pagination = { page: this.page }
|
|
|
}
|
|
|
- // TODO: 分页数据处理
|
|
|
- // 加载数据
|
|
|
- queryDataByKey(ActionUtils.formatParams(params, pagination)).then(response => {
|
|
|
- const dataResult = response.data.dataResult
|
|
|
- if (this.isTree) {
|
|
|
- this.dataList = TreeUtils.transformToTreeFormat(dataResult, {
|
|
|
- idKey: this.idKey,
|
|
|
- parentIdKey: this.parentIdKey,
|
|
|
- childrenKey: this.childrenKey
|
|
|
- })
|
|
|
- // 初始化最顶级数据
|
|
|
- this.initRootTreeData(response.vars)
|
|
|
- // 缓存数据
|
|
|
- dataResult.map((d) => {
|
|
|
- this.cacheData[d[this.valueKey]] = d
|
|
|
- })
|
|
|
- } else {
|
|
|
- this.dataList = dataResult
|
|
|
- this.dataList.map((d) => {
|
|
|
- this.cacheData[d[this.valueKey]] = d
|
|
|
- })
|
|
|
- }
|
|
|
- }).catch((e) => {
|
|
|
- console.error(e)
|
|
|
+ // console.log(!this.isTre, this.page, 'this.pagethis.page')
|
|
|
+ //
|
|
|
+ getByKey({
|
|
|
+ dataTemplateKey: this.templateKey
|
|
|
+ }).then(response => {
|
|
|
+ this.dataTem = this.$utils.parseData(response.data).templates[0]
|
|
|
+ console.log(this.dataTem, 'dadadadadadada')
|
|
|
+ // this.loadAjaxOptions()
|
|
|
+ // TODO: 分页数据处理
|
|
|
+ // 加载数据
|
|
|
+ queryDataByKey(ActionUtils.formatParams(params, pagination)).then(response => {
|
|
|
+ const dataResult = response.data.dataResult
|
|
|
+ const pageResult = response.data.pageResult
|
|
|
+ if (this.isTree) {
|
|
|
+ this.dataList = TreeUtils.transformToTreeFormat(dataResult, {
|
|
|
+ idKey: this.idKey,
|
|
|
+ parentIdKey: this.parentIdKey,
|
|
|
+ childrenKey: this.childrenKey
|
|
|
+ })
|
|
|
+ // 初始化最顶级数据
|
|
|
+ this.initRootTreeData(response.vars)
|
|
|
+ // 缓存数据
|
|
|
+ dataResult.map((d) => {
|
|
|
+ this.cacheData[d[this.valueKey]] = d
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ // const mid = []
|
|
|
+ const dl = dataResult
|
|
|
+ dl.map((d) => {
|
|
|
+ this.cacheData[d[this.valueKey]] = d
|
|
|
+ const objName = Object.keys(d)
|
|
|
+ const fb = {}
|
|
|
+ objName.forEach((it, i) => {
|
|
|
+ let b = {}
|
|
|
+ const keyName = this.dataTem.display_columns.find(t => t.name === it)
|
|
|
+ if (typeof keyName !== 'undefined' && keyName) {
|
|
|
+ b = { 'label': keyName.label, 'val': d[it] }
|
|
|
+ } else {
|
|
|
+ b = d[it]
|
|
|
+ }
|
|
|
+ fb[it] = b
|
|
|
+ })
|
|
|
+ this.dataList.push(fb)
|
|
|
+ })
|
|
|
+ // this.dataList = [this.dataList, ...mid]
|
|
|
+ // console.log(this.dataList, 'this.dataList')
|
|
|
+ }
|
|
|
+ this.page++
|
|
|
+ // 加载状态结束
|
|
|
+ this.loading = false
|
|
|
+ console.log(this.dataList.length >= pageResult.totalCount, this.page > pageResult.totalPages)
|
|
|
+ // 数据全部加载完成
|
|
|
+ if (this.dataList.length >= pageResult.totalCount || this.page > pageResult.totalPages) {
|
|
|
+ this.finished = true
|
|
|
+ }
|
|
|
+ }).catch((e) => {
|
|
|
+ console.error(e)
|
|
|
+ })
|
|
|
+ }).catch(() => {
|
|
|
})
|
|
|
},
|
|
|
/**
|
|
|
@@ -343,6 +400,7 @@ export default {
|
|
|
[this.labelKey]: vars.rootLabel || '顶级',
|
|
|
[this.childrenKey]: this.dataList
|
|
|
}
|
|
|
+ console.log(this.dataList, 'this.dataList')
|
|
|
this.pathData.push(data)
|
|
|
},
|
|
|
|