初始化

This commit is contained in:
aixianling
2021-12-14 18:36:19 +08:00
parent 9afa4101b6
commit a8dff862d2
327 changed files with 88702 additions and 0 deletions

View File

@@ -0,0 +1,71 @@
<template>
<component
v-if="hasApp && configLoaded"
:is="componentName"
:params="params"
:backType="backType"
:instance="instance"
:dict="dict"
:appType="appType"
:appId="appId"
:configs="configs"
@change="changePage" />
<ai-empty v-else-if="hasApp">应用配置加载中...</ai-empty>
<ai-empty v-else>读取应用失败</ai-empty>
</template>
<script>
import Add from './components/Add.vue'
import Detail from './components/Detail.vue'
import List from './components/List.vue'
export default {
label: '代码生成',
name: 'AppCodeGeneration',
props: {
instance: Function,
dict: Object
},
components: {Add, Detail, List},
computed: {
appId() {
return this.$route.query.app
},
hasApp() {
return !!this.appId
},
configLoaded() {
return !!this.configs.id
}
},
data() {
return {
componentName: 'list',
params: {},
backType: '',
configs: {},
appType: ''
}
},
methods: {
changePage(data) {
this.componentName = data.type
this.params = data.params
this.backType = data.backType || ''
},
getConfigs() {
this.instance.post(`/app/appapplicationinfo/queryApplicationInfo`, null, {
params: {appId: this.appId}
}).then((res) => {
if (res?.data) {
this.appType = res.data.appType
this.configs = res.data
}
})
}
},
created() {
this.getConfigs()
}
}
</script>

View File

@@ -0,0 +1,179 @@
<template>
<ai-card title="走访记录" class="visit">
<el-button slot="right" icon="iconfont iconAdd" type="text" @click="isShow = true">添加走访记录</el-button>
<template #content>
<div class="visit-list">
<div class="visit-item" v-for="(item, index) in 10" :key="index">
<div class="visit-item__top">
<div class="left">
<img src="https://p26-passport.byteacctimg.com/img/user-avatar/6401428bcd3b2b9bfed4f31cca07b798~300x300.image">
<h2>且听风吟</h2>
</div>
<span>2020-07-05 12:02:33</span>
</div>
<p>且听风吟且听风吟且听风吟且听风吟且听风吟且听风吟且听风吟且听风吟且听风吟且听风吟且听风吟且听风吟</p>
<div class="visit-imgs">
</div>
<div class="visit-status">
<span>现实状态</span>
<i>失联</i>
</div>
</div>
</div>
<ai-dialog
:visible.sync="isShow"
width="1000px"
height="500px"
title="数据源"
@close="onClose"
@onConfirm="onConfirm">
<el-form ref="form" :model="form" label-width="110px" label-position="right">
<ai-bar title="基本信息">基本信息</ai-bar>
<div class="ai-form">
<el-form-item label="走访人姓名" prop="description">
<span>且听风吟</span>
</el-form-item>
<el-form-item label="身份证账号" prop="description">
<span>2131313</span>
</el-form-item>
<el-form-item label="数据源描述" prop="description" :rules="[{ required: true, message: '请输入数据源描述', trigger: 'blur' }]">
<el-input
size="small"
placeholder="请输入数据源描述"
v-model="form.description">
</el-input>
</el-form-item>
<el-form-item label="村微应用" prop="appId" :rules="[{ required: true, message: '请选择村微应用', trigger: 'change' }]">
<el-select size="small" v-model="form.appId" placeholder="请选择村微应用">
<el-option
v-for="item in appList"
:key="item.id"
:label="item.appName"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</div>
</el-form>
</ai-dialog>
</template>
</ai-card>
</template>
<script>
export default {
name: 'visit',
props: ['id'],
data () {
return {
appList: [],
isShow: false,
form: {
description: '',
appId: ''
}
}
},
methods: {
onConfirm () {
this.$refs.form.validate((valid) => {
if (valid) {
this.instance.post(`/appdiylargescreen/addOrUpdateDatasource`, {
...this.form,
id: this.id ? this.id : ''
}).then(res => {
if (res.code === 0) {
this.$message.success(this.id ? '编辑成功' : '添加成功')
this.isShow = false
this.getList()
}
})
}
})
},
onClose () {
},
getList () {
}
}
}
</script>
<style lang="scss" scoped>
.visit {
.visit-list {
.visit-item {
padding: 10px 0;
border-bottom: 1px solid #eee;
&:first-child {
padding-top: 0;
}
&:last-child {
border-bottom: none;
}
.visit-status {
display: flex;
align-items: center;
font-size: 14px;
span {
color: #333;
}
i {
color: #999;
font-style: normal;
}
}
& > p {
line-height: 1.4;
margin-bottom: 4px;
text-align: justify;
color: #666;
font-size: 16px;
}
.visit-item__top {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 10px;
span {
font-size: 14px;
color: #999;
}
.left {
display: flex;
align-items: center;
img {
width: 40px;
height: 40px;
margin-right: 10px;
border-radius: 50%;
}
h2 {
font-size: 16px;
font-weight: 500;
}
}
}
}
}
}
</style>

View File

@@ -0,0 +1,364 @@
<template>
<ai-detail v-if="pageShow">
<template #title>
<ai-title :title="params.id ? '编辑'+colData.applicationName : '新增' + colData.applicationName" isShowBottomBorder
isShowBack @onBackClick="onBack(true)"></ai-title>
</template>
<template #content>
<el-form ref="formData" class="ai-form" :rules="rules" :model="formData" label-width="110px" size="small">
<ai-card :title="items[0].groupName" v-for="(items, indexs) in formDataList" :key="indexs" v-if="items.length">
<template slot="content">
<div v-for="(item, index) in items" :key="index" :style="item.grid == 1 ? 'width: 100%;' : 'width: 50%;'"
class="form-div">
<el-form-item :label="item.fieldName" :prop="item.fieldDbName" style="width: 100%">
<!-- 字典下拉选择 -->
<template v-if="item.type == 'dict'">
<ai-select v-model="formData[item.fieldDbName]" :placeholder="item.fieldName" :selectList="dict.getDict(item.dict)" :disabled="item.disable == 1" />
</template>
<!-- 单选radio -->
<template v-else-if="item.type == 'radio'">
<el-radio-group v-model="formData[item.fieldDbName]" :disabled="item.disable == 1">
<el-radio :label="item.dictValue" v-for="(item, i) in dict.getDict(item.dict)" :key="i">{{ item.dictName }}</el-radio>
</el-radio-group>
</template>
<!-- 开关onOff -->
<template v-else-if="item.type == 'onOff'">
<el-switch v-model="formData[item.fieldDbName]" active-color="#26f" inactive-color="#ddd" active-value="1" inactive-value="0" :disabled="item.disable == 1"></el-switch>
</template>
<!-- 多选checkbox -->
<template v-else-if="item.type == 'checkbox'">
<el-checkbox-group v-model="formData[item.fieldDbName]" :disabled="item.disable == 1">
<el-checkbox v-for="(item, i) in dict.getDict(item.dict)" :label="item.dictValue" :key="i">
{{ item.dictName }}
</el-checkbox>
</el-checkbox-group>
</template>
<!-- 身份证输入框 -->
<template v-else-if="item.type == 'idNumber'">
<ai-id v-model="formData[item.fieldDbName]" :disabled="item.disable == 1" />
</template>
<!-- input输入框 -->
<template v-else-if="item.type == 'input' || item.type == 'name' || item.type == 'phone'">
<el-input v-model="formData[item.fieldDbName]" :placeholder="'请输入'+item.fieldName" clearable :disabled="item.disable == 1"
:maxlength="item.maxLength" show-word-limit></el-input>
</template>
<!-- number 输入框 -->
<template v-else-if="item.type == 'number'">
<el-input-number v-model="formData[item.fieldDbName]" :label="'请输入'+item.fieldName" :disabled="item.disable == 1" :precision="item.decimalPlaces" :max="item.maxValue" :min="item.minValue"></el-input-number>
</template>
<!-- textarea输入框 -->
<template v-else-if="item.type == 'textarea' || item.type == 'text'">
<el-input v-model="formData[item.fieldDbName]" :placeholder="'请输入'+item.fieldName" clearable :disabled="item.disable == 1"
:maxlength="item.maxLength" type="textarea" show-word-limit :rows="3"></el-input>
</template>
<!-- 日期选择 -->
<template v-else-if="item.type == 'date'">
<el-date-picker v-model="formData[item.fieldDbName]" type="date" placeholder="请选择" :disabled="item.disable == 1"
:value-format="item.timePattern"></el-date-picker>
</template>
<!-- 日期带时分秒选择 -->
<template v-else-if="item.type == 'datetime'">
<el-date-picker v-model="formData[item.fieldDbName]" type="datetime" placeholder="选择日期时间" :disabled="item.disable == 1"
:value-format="item.timePattern"></el-date-picker>
</template>
<!-- 时间-时分秒选择 -->
<template v-else-if="item.type == 'time'">
<el-time-picker v-model="formData[item.fieldDbName]" placeholder="请选择" :disabled="item.disable == 1"
:value-format="item.timePattern"></el-time-picker>
</template>
<!-- 附件 -->
<template v-else-if="item.type == 'upload'">
<ai-uploader :instance="instance" isShowTip fileType="file" v-model="formData[item.fieldDbName]" :disabled="item.disable == 1"
acceptType=".zip,.rar,.doc,.docx,.xls,.ppt,.pptx,.pdf,.txt,.jpg,.png,.xlsx"
:limit="item.fileMaxCount" :maxSize="item.fileChoseSize"></ai-uploader>
</template>
<!-- 富文本 -->
<template v-else-if="item.type == 'rtf'">
<ai-editor v-model="formData[item.fieldDbName]" :instance="instance"/>
</template>
<!-- 地区选择 -->
<template v-else-if="item.type == 'area'">
<ai-area-get :instance="instance" v-model="formData[item.fieldDbName]" :name.sync="formData[item.fieldDbName +'_name']" :disabled="item.disable == 1"/>
</template>
<!-- 人员选择 -->
<div class="especial" v-else-if="item.type == 'user'">
<span class="icon">&nbsp;</span>
<span class="people">{{ item.fieldName }}:</span>
<ai-wechat-selecter slot="append" isShowUser :instance="instance"
v-model="formData[item.fieldDbName]"></ai-wechat-selecter>
</div>
</el-form-item>
</div>
</template>
</ai-card>
</el-form>
</template>
<template #footer>
<el-button class="delete-btn footer-btn" @click="onBack">取消</el-button>
<el-button class="footer-btn" type="primary" @click="submit('formData')">提交</el-button>
</template>
</ai-detail>
</template>
<script>
import {mapState} from 'vuex'
export default {
name: 'Add',
props: {
instance: Function,
params: Object,
dict: Object,
appId: String,
backType: String,
configs: Object
},
data() {
return {
formData: {},
pickerOptions0: {
disabledDate(time) {
return time.getTime() < Date.now() - 8.64e7;
}
},
formDataList: [],
pageShow: false,
colData: {},
areaId: ''
}
},
computed: {
...mapState(['user']),
rules() {
let rules = {}
this.colData?.tableInfos?.map(e => {
rules[e.fieldDbName] = []
if (e.mustFill == 1) {//是否必填
rules[e.fieldDbName]?.push({required: true, message: e.fieldTips})
}
})
return rules
}
},
created() {
this.getFormData()
if (this.params.id) {
this.getDetail()
}
},
methods: {
initForm(data) {
this.colData = data
let dictList = []
let formList = {}
data.tableInfos.map((item) => {
let colItem
if (item.dictionaryCode) {
dictList.push(item.dictionaryCode)
}
if (item.dictionaryCode && item.type != 'radio' && item.type != 'checkbox' && item.type != 'onOff') {
colItem = {
...item,
type: 'dict',
dict: item.dictionaryCode
}
if (!this.params.id) {
colItem.fieldValue = item.defaultValue || ''
}
} else if (item.type == 'radio') {
colItem = {
...item,
dict: item.dictionaryCode,
}
if (!this.params.id) {
colItem.fieldValue = item.defaultValue || ''
}
} else if (item.type == 'checkbox') {
colItem = {
...item,
dict: item.dictionaryCode,
fieldValue: []
}
if (!this.params.id && item.defaultValue) {
var val = item.defaultValue?.split('`')
colItem.fieldValue = val
}
} else if (item.type == 'onOff') {
colItem = {
...item,
}
if (!this.params.id) {
colItem.fieldValue = item.defaultValue || 0
}
} else if (item.type == 'number') {
colItem = {
...item,
type: item.type,
min: item.minValue || '',
max: item.maxValue || ''
}
if (!this.params.id) {
colItem.fieldValue = Number(item.defaultValue) || 0
}
}else {
if (item.type == 'date' && !item.timePattern) {
item.timePattern = 'yyyy-MM-dd'
}
if (item.type == 'datetime' && !item.timePattern) {
item.timePattern = 'yyyy-MM-dd HH:mm:ss'
}
if (item.type == 'time' && !item.timePattern) {
item.timePattern = 'HH:mm:ss'
}
colItem = {
...item,
type: item.type,
}
if (!this.params.id) {
colItem.fieldValue = item.defaultValue || ''
}
}
// console.log(colItem)
formList[item.groupIndex]?.push(colItem) || (formList[item.groupIndex] = [colItem])
this.$set(this.formData, colItem.fieldDbName, colItem.fieldValue || "")
})
this.formDataList = Object.values(formList)
this.$forceUpdate()
if (dictList.length) {
this.getDictList(dictList)
} else {
this.pageShow = true
}
},
getFormData() {
this.initForm(this.configs)
},
getDetail() {
this.instance.post(`/app/appapplicationinfo/queryDetailById?appId=${this.appId}&id=${this.params.id}`).then((res) => {
if (res?.data) {
this.formData = res.data
this.configs.tableInfos.map((item) => {
if(item.type == 'checkbox') {
var checkList = this.formData[item.fieldDbName]?.split(',')
this.formData[item.fieldDbName] = checkList
}
})
}
})
},
getDictList(listName) {
this.dict.load(listName.join(',')).then(() => {
this.pageShow = true
})
},
submit() {
this.$refs.formData?.validate((valid) => {
if (valid) {
this.formDataList.map((item) => {
if (item.length) {
item.map((items) => {
if (items.type == 'checkbox' && this.formData[items.fieldDbName].length) { //多选
this.formData[items.fieldDbName] = this.formData[items.fieldDbName]?.toString()
}
if (items.type == 'upload' && this.formData[items.fieldDbName].length) { //附件 只传id
var files = []
this.formData[items.fieldDbName].map((item) => {
files.push(item.id)
})
this.formData[items.fieldDbName] = files.join(',')
}
if(items.type == 'area' && this.formData[items.fieldDbName]) {
var area = []
area.push(this.formData[items.fieldDbName])
area.push(this.formData[items.fieldDbName+'_name'])
this.formData[items.fieldDbName] = area.join('_')
}
})
}
})
this.instance.post(`/app/appapplicationinfo/addOrUpdate?appId=${this.appId}`, {
...this.formData,
id: this.params.id || ''
}).then((res) => {
if (res.code == 0) {
this.$message.success('提交成功')
setTimeout(() => {
this.onBack(true)
}, 600)
}
})
}
})
},
onBack(isRefresh) {
this.$emit('change', {
type: this.backType == 'Detail' ? 'detail' : 'list',
params: this.params,
isRefresh: !!isRefresh,
})
},
},
}
</script>
<style scoped lang="scss">
::v-deep .ai-card{
width: 100%;
}
.form-div {
display: inline-block;
vertical-align: top;
}
.especial {
margin-bottom: 12px;
.icon {
vertical-align: top;
display: inline-block;
padding-top: 5px;
margin-left: 20px;
color: #f46;
}
.people {
display: inline-block;
font-size: 14px;
color: #666;
padding-right: 12px;
vertical-align: top;
width: 64px;
word-break: break-all;
box-sizing: border-box;
}
.AiWechatSelecter {
display: inline-block;
margin-left: 3px;
}
.hint {
font-size: 14px;
color: #999;
margin-left: 16px;
}
.mar-r40 {
margin-right: 40px;
}
.w80 {
width: 80px;
text-align: right;
color: #888;
}
}
.AiWechatSelecter {
width: calc(100% - 120px);
}
</style>

View File

@@ -0,0 +1,236 @@
<template>
<ai-detail v-if="pageShow">
<template #title>
<ai-title :title="colData.applicationName+'详情'" isShowBottomBorder isShowBack @onBackClick="onBack(true)"></ai-title>
</template>
<template #content>
<AiSidebar :tabTitle="tabTitle" v-model="currIndex" v-if="appType"></AiSidebar>
<ai-card v-show="currIndex === 0" :title="items[0].groupName" v-for="(items, indexs) in formDataList" :key="indexs">
<template slot="content">
<ai-wrapper class="mar-t16" label-width="80px" :columnsNumber="1">
<div v-for="(item, index) in items" :key="index" :style="item.grid == 0.5 ? 'width: 50%;': 'width: 100%;'" class="form-div">
<ai-info-item :label="item.fieldName+ ''">
<span v-if="item.dict && item.type != 'checkbox'">{{$dict.getLabel(item.dict, formData[item.fieldDbName]) || '-'}}</span>
<span v-if="!item.dict && item.type != 'rtf' && item.type != 'upload' && item.type != 'area'">{{formData[item.fieldDbName]}}</span>
<span v-if="item.type == 'checkbox'">{{formData[item.fieldDbName]}}</span>
<span v-if="item.type == 'rtf'" v-html="formData[item.fieldDbName]"></span>
<ai-file-list :fileList="formData[item.fieldDbName]" v-if="item.type == 'upload'" :fileOps="{name: 'name', size: 'fileSizeStr'}"></ai-file-list>
<span v-if="item.type == 'area'" v-html="formData[item.fieldDbName+'_name']"></span>
</ai-info-item>
</div>
</ai-wrapper>
</template>
</ai-card>
<component :is="component" v-if="currIndex === 1"></component>
</template>
</ai-detail>
</template>
<script>
import { mapState } from 'vuex'
import Visit from './../app/visit/Visit'
export default {
name: 'Detail',
props: {
dict: Object,
appId: String,
params: Object,
configs: Object,
appType: String,
instance: Function
},
components: {
Visit
},
data () {
return {
formData: {},
colData: {},
formDataList: [],
tabTitle: ['人员信息'],
pageShow: false,
currIndex: 0,
component: ''
}
},
computed: {
...mapState(['user']),
},
created () {
if (!this.appType) return
if (this.appType === '0') {
this.component = 'Visit'
}
this.dict.load('diyAppType').then(() => {
this.tabTitle.push(this.dict.getLabel('diyAppType', this.appType))
})
},
mounted () {
this.getFormData()
this.getDetail()
},
methods: {
initForm (data) {
this.colData = data
let dictList = []
let formList = {}
data.tableInfos.map((item) => {
let colItem
if (item.dictionaryCode) {
dictList.push(item.dictionaryCode)
}
if (item.dictionaryCode && item.type != 'radio' && item.type != 'checkbox') {
colItem = {
...item,
type: 'dict',
dict: item.dictionaryCode
}
} else if (item.type == 'radio') {
colItem = {
...item,
dict: item.dictionaryCode,
}
} else if (item.type == 'checkbox') {
colItem = {
...item,
dict: item.dictionaryCode,
fieldValue: item.fieldValue?.split(',') || []
}
} else if (item.type == 'onOff') {
colItem = {
...item,
fieldValue: 0
}
} else {
if (item.type == 'date' && !item.timePattern) {
item.timePattern = 'yyyy-MM-dd'
}
if (item.type == 'datetime' && !item.timePattern) {
item.timePattern = 'HH:mm:ss yyyy-MM-dd'
}
if (item.type == 'time' && !item.timePattern) {
item.timePattern = 'HH:mm:ss'
}
colItem = {
...item,
type: item.type,
}
}
formList[item.groupIndex]?.push(colItem) || (formList[item.groupIndex] = [colItem])
this.$set(this.formData, colItem.fieldDbName, colItem.fieldValue || "")
})
this.formDataList = Object.values(formList)
this.$forceUpdate()
if (dictList.length) {
this.getDictList(dictList)
} else {
this.pageShow = true
}
},
getFormData () {
this.initForm(this.configs)
},
getDetail () {
this.instance.post(`/app/appapplicationinfo/queryDetailById?appId=${this.appId}&id=${this.params.id}`).then((res) => {
if (res?.data) {
this.formData = res.data
}
})
},
getDictList (listName) {
this.dict.load(listName.join(',')).then(() => {
this.pageShow = true
})
},
onBack (isRefresh) {
this.$emit('change', {
type: 'list',
isRefresh: !!isRefresh,
})
},
toEdit () {
this.$emit('change', {
type: 'Add',
params: this.params,
backType: 'Detail'
})
}
}
}
</script>
<style scoped lang="scss">
.form-div{
display: inline-block;
}
.especial {
margin-bottom: 12px;
.icon {
vertical-align: top;
display: inline-block;
padding-top: 5px;
margin-left: 20px;
color: #f46;
}
.people {
display: inline-block;
font-size: 14px;
color: #666;
margin-right: 16px;
vertical-align: top;
}
.AiWechatSelecter {
display: inline-block;
margin-left: 3px;
}
.hint {
font-size: 14px;
color: #999;
margin-left: 16px;
}
.mar-r40{
margin-right: 40px;
}
.w80{
width: 80px;
text-align: right;
color: #888;
}
}
.add-icon{
text-align: right;
cursor: pointer;
i{
font-size: 14px;
}
}
.color1{
color:#4B87FE;
}
.color2{
color:#2EA222;
}
.color3{
color:#999999;
}
.AiWechatSelecter{
width: calc(100% - 150px);
}
</style>

View File

@@ -0,0 +1,302 @@
<template>
<ai-list v-if="pageShow">
<template slot="title">
<ai-title :title="configs.applicationName" isShowBottomBorder></ai-title>
</template>
<template slot="content">
<ai-search-bar v-if="searchList.length">
<template #left>
<div v-for="(item, index) in searchList" :key="index">
<ai-select
v-model="search[item.searchValue]"
:placeholder="'请选择'+item.label" clearable
@change="$forceUpdate();(page.current = 1), getList()"
:selectList="dict.getDict(item.dict)"
v-if="item.type == 'dict'">
</ai-select>
<ai-search v-else-if="item.type == 'date'" :label="item.label">
<el-date-picker size="small" v-model="search[item.searchValue]" type="daterange" range-separator="至"
start-placeholder="开始日期" end-placeholder="结束日期"
@change="$forceUpdate();(page.current = 1), getList()"
value-format="yyyy-MM-dd"/>
</ai-search>
<ai-search v-else-if="item.type == 'time'" :label="item.label">
<el-time-picker is-range size="small" v-model="search[item.searchValue]" range-separator="至"
start-placeholder="开始时间" end-placeholder="结束时间" placeholder="选择时间范围"
@change="$forceUpdate();(page.current = 1), getList()"
value-format="HH:mm:ss"></el-time-picker>
</ai-search>
<ai-search v-else-if="item.type == 'area'" :label="item.label">
<ai-area-get :instance="instance" v-model="search[item.searchValue]"/>
</ai-search>
</div>
</template>
<template #right v-if="showRightInput">
<el-input :placeholder="placeholder" v-model="search.searchParam" size="small"
@change="$forceUpdate();(page.current = 1), getList()" clearable prefix-icon="iconfont iconSearch"/>
</template>
</ai-search-bar>
<ai-search-bar>
<template #left>
<el-button type="primary" icon="iconfont iconAdd" size="small"
v-if="configs.insertEnable == 1" @click="toAdd('', 'Add')">添加
</el-button>
<el-button icon="iconfont iconDelete" size="small" :disabled="ids.length == 0"
v-if="configs.batchDelEnable == 1" @click="delAll()">删除
</el-button>
</template>
<template #right>
<ai-import :instance="instance" v-if="configs.importEnable == 1" type="appapplicationinfo"
:importParams="{appId}" :tplParams="{appId}" :name="configs.applicationName" @success="getList()">
<el-button icon="iconfont iconImport">导入</el-button>
</ai-import>
<el-button icon="iconfont iconExported" size="small" v-if="configs.exportEnalbe == 1" @click="down()"
>导出
</el-button>
</template>
</ai-search-bar>
<ai-table class="ai-table" :tableData="tableData" :col-configs="colConfigs" :total="page.total"
:current.sync="page.current" :size.sync="page.size" @getList="getList" :dict="dict"
@selection-change="(v) => (ids = v.map((e) => e.id))">
<el-table-column v-for="(item, indexs) in colConfigs" :key="indexs" :slot="item.slot" :label="item.label"
show-overflow-tooltip
align="center">
<template slot-scope="{ row }">
<div v-if="item.type != 'checkbox' && item.dict">
{{ $dict.getLabel(item.dict, row[item.fieldDbName]) || '-' }}
</div>
<div v-if="item.type == 'rtf'" v-html="row[item.fieldDbName]"></div>
<div v-if="item.type == 'checkbox'">{{ row[item.fieldDbName] }}</div>
</template>
</el-table-column>
<el-table-column slot="options" label="操作" align="center" width="200">
<template slot-scope="{ row }">
<div class="table-options">
<el-button type="text" @click="toDetail(row, 'Detail')">详情</el-button>
<el-button type="text" @click="toDetail(row, 'Add')" v-if="configs.editEnable == 1">编辑</el-button>
<el-button type="text" @click="del(row.id)" v-if="configs.deleteEnable == 1">删除</el-button>
</div>
</template>
</el-table-column>
</ai-table>
</template>
</ai-list>
</template>
<script>
export default {
name: 'List',
props: {
instance: Function,
dict: Object,
params: Object,
appId: String,
configs: Object
},
data() {
return {
pageShow: false,
tableData: [],
colConfigs: [],
page: {
size: 10,
current: 1,
total: 0,
},
search: {
searchParam: '',
},
searchList: [],
ids: [],
showRightInput: false,
placeholder: '请输入',
}
},
created() {
this.initConfigs()
},
methods: {
initConfigs() {
var dictList = []
var colList = []
var searchList = []
var placeholderList = []
this.configs.showListFields.map((item) => {
var colItem
if (item.dictionaryCode) {
dictList.push(item.dictionaryCode)
colItem = {
slot: item.fieldDbName,
label: item.fieldName,
dict: item.dictionaryCode,
fieldDbName: item.fieldDbName,
type: item.type
}
} else if (item.type == 'rtf') {
colItem = {label: item.fieldName, type: item.type, slot: item.fieldDbName, fieldDbName: item.fieldDbName}
} else if (item.type == 'area') {
colItem = {prop: item.fieldDbName + '_name', label: item.fieldName, align: "center"}
} else {
colItem = {prop: item.fieldDbName, label: item.fieldName, align: "center"}
}
colList.push(colItem)
})
this.configs.fuzzyQueryFields.map((item) => {
var searchItem = {}
if (item.dictionaryCode) {
searchItem = {
type: 'dict',
label: item.fieldName,
dict: item.dictionaryCode,
searchValue: item.fieldDbName
}
}
if (item.type == 'input' || item.type == 'name' || item.type == 'idNumber' || item.type == 'phone') {
placeholderList.push(item.fieldName)
this.showRightInput = true
}
if (item.type == 'date') {
searchItem = {
type: 'date',
label: item.fieldName,
searchValue: item.fieldDbName
}
}
if (item.type == 'time') {
searchItem = {
type: 'time',
label: item.fieldName,
searchValue: item.fieldDbName
}
}
if (item.type == 'area') {
searchItem = {
type: 'area',
label: item.fieldName,
searchValue: item.fieldDbName
}
}
this.$set(this.search, item.fieldDbName, '')
searchList.push(searchItem)
})
this.colConfigs = colList
this.searchList = searchList
this.$forceUpdate()
var text = placeholderList.join('/')
this.placeholder = this.placeholder + text
if (this.configs.batchDelEnable == 1) {
this.colConfigs.unshift({type: 'selection', width: 100})
}
if (dictList.length) {
this.getDictList(dictList)
} else {
this.pageShow = true
this.getList()
}
},
getDictList(listName) {
this.dict.load(listName.join(',')).then(() => {
this.pageShow = true
this.getList()
})
},
getList() {
this.instance.post(`/app/appapplicationinfo/list?appId=${this.appId}&current=${this.page.current}&size=${this.page.size}`, {...this.search}).then((res) => {
if (res?.data) {
this.tableData = res.data.records
this.page.total = res.data.total
}
})
},
toDetail(item, type) {
this.$emit('change', {
type: type,
params: item,
backType: 'List'
})
},
toAdd() {
this.$emit('change', {
type: 'Add',
params: {
type: 'Add',
}
})
},
del(id) {
this.$confirm("删除后不可恢复是否要删除", {
type: 'error'
}).then(() => {
this.instance.post(`/app/appapplicationinfo/delete?appId=${this.appId}&ids=${id}`).then((res) => {
if (res.code == 0) {
this.$message.success("删除成功");
this.getList();
}
})
});
},
delAll() {
if (this.ids.length > 100) {
return this.$message.error("删除的数据最多不能超过100条");
}
var id = this.ids.join(',')
this.del(id)
},
reset() {
Object.keys(this.search).forEach((e) => {
this.search[e] = ''
})
this.getList()
},
down() {
var id = ''
if (this.ids.length) {
id = this.ids.join(',')
}
this.instance.post(`/app/appapplicationinfo/export?appId=${this.appId}&ids=${id}`, this.search, {
responseType: 'blob',
timeout: 100000
}).then(res => {
if (res?.type == "application/json") {
let reader = new FileReader()
reader.readAsText(res, "utf-8")
reader.onload = e => {
if (e.target.readyState === 2) {
let ret = JSON.parse(e.target.result)
if (ret?.code == 0) {
this.$message.success(ret.msg)
} else this.$message.error(ret.msg)
}
}
} else {
const link = document.createElement('a')
let blob = new Blob([res], {type: res.type})
link.style.display = 'none'
link.href = URL.createObjectURL(blob)
link.setAttribute('download', this.configs.applicationName + '.xls')
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
}
}).catch((err) => {
this.$error.success(err)
})
}
},
}
</script>
<style scoped lang="scss">
.mar-b10 {
margin-bottom: 10px;
}
</style>