迁移一个代码生成

This commit is contained in:
aixianling
2022-06-08 15:44:13 +08:00
parent fa7c5428c5
commit 3365fcb1ef
5 changed files with 1398 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,230 @@
<template>
<ai-card title="走访记录" class="visit" v-loading="loading">
<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 list" :key="index">
<div class="visit-item__top">
<div class="left">
<div class="avatar">{{ item.name.substr(item.name.length - 2) }}</div>
<h2>{{ item.name }}</h2>
</div>
<span>{{ item.visitTime }}</span>
</div>
<b>{{ item.title }}</b>
<p>{{ item.description }}</p>
<div class="visit-imgs" v-if="item.images.length">
<ai-uploader v-model="item.images" :instance="instance" :limit="9" disabled/>
</div>
<div class="visit-status">
<span>现实状态</span>
<i>{{ dict.getLabel('visitCondolenceReality', item.reality) }}</i>
</div>
</div>
<ai-empty v-if="!list.length"></ai-empty>
</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" size="small">
<ai-bar title="走访记录"></ai-bar>
<div class="ai-form" :model="form" label-width="110px" label-position="right">
<el-form-item label="走访时间" prop="visitTime"
:rules="[{ required: true, message: '请选择走访时间', trigger: 'change' }]">
<el-date-picker
v-model="form.visitTime"
type="datetime"
style="width: 100%;"
value-format="yyyy-MM-dd HH:mm:ss"
placeholder="请选择走访时间">
</el-date-picker>
</el-form-item>
<el-form-item label="现实状态" prop="reality"
:rules="[{ required: true, message: '请选择现实状态', trigger: 'change' }]">
<ai-select
v-model="form.reality"
:selectList="dict.getDict('visitCondolenceReality')"
laceholder="请选择现实状态">
</ai-select>
</el-form-item>
<el-form-item label="入户走访事项" prop="title" style="width: 100%;"
:rules="[{ required: true, message: '请输入 入户走访事项'}]">
<el-input placeholder="请输入 入户走访事项" v-model="form.title" maxlength="30" show-word-limit/>
</el-form-item>
<el-form-item label="入户走访内容" prop="description" style="width: 100%;">
<el-input type="textarea" placeholder="请输入 入户走访内容" v-model="form.description" :rows="4" maxlength="500"
show-word-limit/>
</el-form-item>
<el-form-item label="图片" prop="images" style="width: 100%;">
<ai-uploader v-model="form.images" :instance="instance" :limit="9" isShowTip/>
</el-form-item>
</div>
</el-form>
</ai-dialog>
</template>
</ai-card>
</template>
<script>
import {mapState} from 'vuex'
export default {
name: 'visit',
props: ['id', 'dict', 'instance', 'appId', 'name', 'areaId'],
data() {
return {
appList: [],
list: [],
loading: false,
isShow: false,
form: {
visitTime: '',
reality: '',
images: [],
description: ''
}
}
},
computed: {
...mapState(['user'])
},
mounted() {
this.dict.load('visitCondolenceReality').then(() => {
this.getList()
})
},
methods: {
getList() {
this.loading = true
this.instance.post(`/app/appvisitvondolence/list?optionId=${this.id}&size=10000`).then(res => {
if (res.code === 0) {
this.list = res.data.records.map(item => {
return {
...item,
images: item.images ? JSON.parse(item.images) : []
}
})
}
this.loading = false
})
},
onConfirm() {
this.$refs.form.validate((valid) => {
if (valid) {
this.instance.post(`/app/appvisitvondolence/addOrUpdate`, {
...this.form,
optionId: this.id,
images: JSON.stringify(this.form.images),
applicationId: this.appId,
name: this.name,
areaId: this.areaId
}).then(res => {
if (res.code === 0) {
this.$message.success('添加成功')
this.isShow = false
this.getList()
}
})
}
})
},
onClose() {
this.form = {}
}
}
}
</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;
}
b {
display: block;
margin-bottom: 6px;
}
.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, .avatar {
width: 40px;
height: 40px;
line-height: 40px;
text-align: center;
margin-right: 10px;
border-radius: 50%;
font-size: 14px;
color: #fff;
background: #26f;
}
h2 {
font-size: 16px;
font-weight: 500;
}
}
}
}
}
}
</style>

View File

@@ -0,0 +1,533 @@
<template>
<ai-detail v-if="pageShow" class="add-form">
<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 || !!(formData.resident_id && item.isInit)" />
</template>
<!-- 单选radio -->
<template v-else-if="item.type == 'radio'">
<el-radio-group v-model="formData[item.fieldDbName]" :disabled="item.disable == 1 || !!(formData.resident_id && item.isInit)">
<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 || !!(formData.resident_id && item.isInit)"></el-switch>
</template>
<!-- 多选checkbox -->
<template v-else-if="item.type == 'checkbox'">
<el-checkbox-group v-model="formData[item.fieldDbName]" :disabled="item.disable == 1 || !!(formData.resident_id && item.isInit)">
<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 === 'gird'">
<el-input disabled :value="girdName" size="small" placeholder="请选择网格">
<template slot="append">
<el-button size="small" @click="showGrid = true, treeObj.checkedKeys = formData[item.fieldDbName] ? [formData[item.fieldDbName]] : [], gridFieldName = item.fieldDbName">选择网格</el-button>
</template>
</el-input>
</template>
<template v-else-if="item.type === 'resident'">
<el-input
v-model="formData.name"
:placeholder="'请选择'+item.fieldName">
<template slot="append">
<ai-person-select
:instance="instance"
:disabled="!!params.id"
:url="'/app/appresident/list?auditType=1&areaId=' + user.info.areaId"
:isMultiple="false" dialogTitle="选择" @selectPerson="onChange">
<template name="option" v-slot:option="{ item }">
<span class="iconfont iconProlife">{{ item.name }}</span>
<ai-id mode="show" :show-eyes="false" :value="item.idNumber"/>
</template>
</ai-person-select>
</template>
</el-input>
</template>
<template v-else-if="item.type == 'idNumber'">
<ai-id v-model="formData[item.fieldDbName]" :disabled="item.disable == 1 || !!(formData.resident_id && item.isInit)" />
</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 || !!(formData.resident_id && item.isInit)"
: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 || !!(formData.resident_id && item.isInit)" :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 || !!(formData.resident_id && item.isInit)"
:maxlength="item.maxLength" type="textarea" show-word-limit :rows="3"></el-input>
</template>
<!-- 日期选择 -->
<template v-else-if="item.type == 'date'">
<el-date-picker style="width: 100%;" v-model="formData[item.fieldDbName]" type="date" placeholder="请选择" :disabled="item.disable == 1 || !!(formData.resident_id && item.isInit)"
: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 || !!(formData.resident_id && item.isInit)"
: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 || !!(formData.resident_id && item.isInit)"
: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" :disabled="item.disable == 1 || !!(formData.resident_id && item.isInit)"/>
</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 || !!(formData.resident_id && item.isInit)"/>
</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>
<ai-dialog
title="选择网格"
:visible.sync="showGrid"
:destroyOnClose="true"
@close="showGrid = false"
@onConfirm="getCheckedTree"
width="720px">
<div class="grid">
<el-tree
:data="treeObj.treeList"
:props="treeObj.defaultProps"
node-key="id"
ref="tree"
:check-strictly="true"
show-checkbox
:default-checked-keys="treeObj.checkedKeys"
default-expand-all
@check="onCheckChange">
</el-tree>
</div>
</ai-dialog>
</template>
<template #footer>
<el-button class="delete-btn footer-btn" @click="onBack">取消</el-button>
<el-button class="footer-btn" type="primary" :loading="isLoading" @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: {
age: 2
},
pickerOptions0: {
disabledDate(time) {
return time.getTime() < Date.now() - 8.64e7;
}
},
isLoading: false,
girdName: '',
gridFieldName: '',
showGrid: false,
formDataList: [],
pageShow: true,
treeObj: {
treeList: [],
defaultProps: {
children: "girdList",
label: "girdName",
},
checkedKeys: [],
},
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.getGridList()
this.getFormData()
if (this.params.id) {
this.getDetail()
}
},
methods: {
getGridList() {
this.instance.post(`/app/appgirdinfo/listAll`).then((res) => {
if (res.code == 0) {
this.treeObj.treeList = this.format(res.data)
if (this.formData.girdId) {
this.$set(this.treeObj, 'checkedKeys', [this.formData.girdId])
}
}
})
},
onChange (e) {
this.formData.resident_id = e.id
Object.keys(this.formData).forEach(item => {
for (var p in e){
if (item === p) {
this.$set(this.formData, item, e[item])
}
}
})
const idNumberInfo = this.idCardNoUtil.getIdCardInfo(e.idNumber)
this.$set(this.formData, 'birthDate', idNumberInfo.birthday)
this.formData.photo = e.photo ? [{
url: e.photo
}] : []
},
getCheckedTree() {
const gird = this.$refs.tree.getCheckedNodes()
if (gird.length) {
this.girdName = gird[0].girdName
this.formData[this.gridFieldName] = gird[0].id
} else {
this.girdName = ''
this.formData[this.gridFieldName] = ''
}
this.showGrid = false
},
onCheckChange (e) {
this.$nextTick(() => {
this.$refs.tree.getCheckedKeys().forEach(v => {
this.$refs.tree.setChecked(v, false)
})
this.$refs.tree.setChecked(e.id, true)
})
},
format (list) {
return list.map(item => {
if (item.girdLevel !== '2') {
item.disabled = true
}
if (item.girdList && item.girdList.length) {
item.girdList = this.format(item.girdList)
}
return item
})
},
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 === 'upload') {
colItem = {
...item,
fieldValue: []
}
} 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 || 1,
max: item.maxValue || 1000000000,
minValue: item.minValue || 1,
maxValue: item.maxValue || 1000000000
}
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])
if (item.type === 'number') {
this.$set(this.formData, item.fieldDbName, 1)
} else {
this.$set(this.formData, item.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.configs.tableInfos.map((item) => {
this.formData[item.fieldDbName] = res.data[item.fieldDbName] || ''
if(item.type == 'checkbox') {
var checkList = this.formData[item.fieldDbName]?.split(',')
this.formData[item.fieldDbName] = checkList
}
if (item.type === 'gird' && this.formData[item.fieldDbName]) {
this.girdName = res.data[`${item.fieldDbName}_name`]
}
if (item.type === 'upload' && !this.formData[item.fieldDbName]) {
this.formData[item.fieldDbName] = []
}
if (item.type === 'upload' && this.formData[item.fieldDbName]) {
this.formData[item.fieldDbName] = this.formData[item.fieldDbName].split(',').map(v => {
return {
url: v
}
})
}
})
}
})
},
getDictList(listName) {
this.dict.load(listName.join(',')).then(() => {
this.pageShow = true
})
},
submit() {
this.$refs.formData?.validate((valid) => {
if (valid) {
this.isLoading = true
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] = this.formData[items.fieldDbName].map(v => v.url).join(',')
}
if(items.type == 'gird' && this.formData[items.fieldDbName]) {
this.formData[items.fieldDbName] = this.formData[items.fieldDbName] + '_' + this.girdName
}
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) => {
this.isLoading = false
if (res.code == 0) {
this.$message.success('提交成功')
setTimeout(() => {
this.onBack(true)
}, 600)
}
}).catch(() => {
this.isLoading = false
})
}
})
},
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;
}
.add-form {
::v-deep .AiPersonSelect {
.el-button {
border-color: transparent;
background-color: transparent;
color: inherit;
border-top: 0;
border-bottom: 0;
background: transparent;
}
}
}
.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,257 @@
<template>
<ai-detail v-loading="pageShow" isHasSidebar>
<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>
<ai-info-item :label="item.fieldName" v-show="item.type !== 'resident'" v-for="(item, index) in items" :key="index" :isLine="item.grid == 1">
<span v-if="item.dict && item.type != 'checkbox'">{{$dict.getLabel(item.dict, formData[item.fieldDbName]) || '-'}}</span>
<span v-else-if="item.type == 'checkbox'">{{formData[item.fieldDbName]}}</span>
<span v-else-if="item.type == 'rtf'" v-html="formData[item.fieldDbName]"></span>
<ai-file-list :fileList="formData[item.fieldDbName]" v-else-if="item.type == 'upload'" :fileOps="{name: 'name', size: 'fileSizeStr'}"></ai-file-list>
<span v-else-if="item.type == 'area'">{{ formData[item.fieldDbName + '_name'] }}</span>
<span v-else-if="item.type == 'gird'">{{ formData[item.fieldDbName + '_name'] }}</span>
<span v-else>{{ formData[item.fieldDbName] || '-' }}</span>
</ai-info-item>
</ai-wrapper>
</template>
</ai-card>
<component
:is="component"
:name="params.name || params.name00"
:areaId="formData.area"
:id="params.id"
:appId="appId"
:dict="dict"
:instance="instance"
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.pageShow = true
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])
if (item.type === 'upload') {
this.$set(this.formData, colItem.fieldDbName, this.formData[colItem.fieldDbName] ? this.formData[colItem.fieldDbName].split(',').map(v => {
return {
url: v
}
}) : [])
} else {
this.$set(this.formData, colItem.fieldDbName, this.formData[colItem.fieldDbName] || "")
}
})
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.getFormData()
this.pageShow = false
}
}).catch(() => {
this.pageShow = false
})
},
getDictList (listName) {
this.dict.load(listName.join(',')).then(() => {
})
},
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,307 @@
<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" bottomBorder style="margin-bottom: 12px;">
<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"
@keyup.enter.native="$forceUpdate();(page.current = 1), getList()"
@clear="$forceUpdate();(page.current = 1), getList()"
@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>
<div v-if="item.type == 'gird'">{{ row[item.fieldDbName + '_name'] }}</div>
</template>
</el-table-column>
<el-table-column slot="options" label="操作" fixed="right" align="center" width="160">
<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 if (item.type == 'gird') {
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>