Files
dvcp_v2_webapp/project/oms/apps/develop/AppDeployCustom/add.vue

352 lines
17 KiB
Vue
Raw Normal View History

2022-07-01 18:26:52 +08:00
<template>
<section class="add">
<ai-detail>
<ai-title slot="title" :title="pageTitle" isShowBottomBorder/>
<template #content>
<el-tabs tab-position="left">
<el-tab-pane label="方案设置">
<el-form ref="AddForm" :model="form" size="small" label-width="120px" :rules="rules">
<ai-card title="基本信息">
<template #content>
<el-form-item label="项目/系统名称" prop="name">
<el-input v-model="form.name" placeholder="请输入" clearable/>
2022-07-04 14:48:21 +08:00
</el-form-item>
<el-row type="flex">
<div class="fill">
<el-form-item label="系统类型" prop="type">
2022-07-14 10:11:17 +08:00
<ai-select v-model="form.type" :selectList="dict.getDict('systemType')" @change="form.apps = [],handleSysTypeChange(form.type)"/>
</el-form-item>
<el-form-item label="更新项目路径" prop="dist">
<el-input v-model="form.dist" placeholder="常填写nginx路径,下载包从这里取" clearable/>
</el-form-item>
</div>
<div class="fill mar-l16">
<el-form-item label="库项目根路径" prop="customPath">
<el-input v-model="form.customPath" placeholder="请输入" clearable/>
</el-form-item>
<el-form-item label="版本号" prop="version">
<el-input v-model="form.version" placeholder="请输入" clearable/>
</el-form-item>
</div>
</el-row>
</template>
</ai-card>
<ai-card title="主库应用">
<template #content>
<ai-lib-table v-if="form.type" v-model="form.apps" v-bind="$props" multiple searchKey="name"
2022-07-13 11:09:06 +08:00
:action="`/node/wechatapps/list?type=${form.type}&isMain=1`" border/>
<ai-empty v-else>请先选择系统类型</ai-empty>
</template>
</ai-card>
<ai-card title="扩展设置">
<template #right>
<template v-if="form.type=='web'">
<ai-dialog-btn text="设置系统信息" dialogTitle="系统信息">
<el-form size="small" label-width="140px">
<el-form-item label="系统标题">
<el-input v-model="form.sysInfo.fullTitle" placeholder="请输入..." clearable/>
</el-form-item>
2022-08-29 09:51:46 +08:00
<el-form-item label="favicon">
<el-input v-model="form.sysInfo.favicon" placeholder="请输入..." clearable/>
</el-form-item>
<el-form-item label="logo">
<el-row type="flex">
<el-input v-model="form.sysInfo.logo" placeholder="请输入..." clearable/>
<el-input class="mar-l10" v-model="form.sysInfo.logoText" placeholder="logo文字">
<template #prepend>logo文字</template>
</el-input>
</el-row>
</el-form-item>
<el-form-item label="登录页">
2022-09-05 10:00:38 +08:00
<el-row type="flex" class="mar-b10">
<el-input v-model="form.sysInfo.loginLogo" placeholder="登录页左上角logo,带/代表图片" clearable>
<template #prepend>左页首logo</template>
</el-input>
<el-input class="mar-l10" v-model="form.sysInfo.loginLogoText" placeholder="logo文字" clearable>
<template #prepend>logo文字</template>
</el-input>
</el-row>
<el-row type="flex">
<el-input v-model="form.sysInfo.name" placeholder="左上角标题" clearable>
<template #prepend>左上角标题</template>
</el-input>
<el-input class="mar-l10" v-model="form.sysInfo.title" placeholder="左上角副标题" clearable>
<template #prepend>左上角副标题</template>
</el-input>
</el-row>
<el-input class="mar-t10" type="textarea" rows="5" v-model="form.sysInfo.desc" placeholder="副标题" clearable/>
</el-form-item>
<el-row type="flex">
<div class="fill">
<el-form-item label="版权所有">
<el-input v-model="form.sysInfo.recordDesc" placeholder="请输入..." clearable/>
</el-form-item>
<el-form-item label="备案号">
<el-input v-model="form.sysInfo.recordNo" placeholder="请输入..." clearable/>
</el-form-item>
</div>
<div class="fill">
<el-form-item label="框架版本">
<!--edition 版本标准版standard上架版saas 简易版(不带扫码):simple -->
<el-input v-model="form.sysInfo.edition" placeholder="请输入..." clearable/>
</el-form-item>
<el-form-item label="备案跳转链接">
<el-input v-model="form.sysInfo.recordURL" placeholder="请输入..." clearable/>
</el-form-item>
</div>
</el-row>
</el-form>
</ai-dialog-btn>
</template>
</template>
<template #content>
2022-07-14 10:11:17 +08:00
<template v-if="form.type=='mp'">
2022-07-14 11:52:00 +08:00
<el-form-item label="小程序AppId">
<el-input v-model="form.appId" clearable placeholder="小程序appId"/>
</el-form-item>
<el-form-item label="半屏小程序">
<el-input v-model="form.embeddedAppIdList" clearable placeholder="如果有多个,请用英文','分割"/>
</el-form-item>
2022-11-02 17:37:56 +08:00
<el-form-item label="接口是否单服务">
<el-checkbox v-model="form.isSingleService"/>
</el-form-item>
2022-07-15 18:12:50 +08:00
<ai-title title="底部导航栏"/>
<ai-table :tableData="tabBar.list" :colConfigs="colConfigs" tableSize="mini" :isShowPagination="false" border>
<el-table-column slot="options" label="操作" width="140" align="center">
<template slot-scope="{row,$index}">
<el-row type="flex" justify="center">
<ai-dialog-btn text="更换" dialogTitle="选择应用">
<ai-lib-table :meta="appList" v-model="row.id" @select="v=>handleTabbarChange(row,v)" :isShowPagination="false" v-bind="$props"
:border="false"/>
</ai-dialog-btn>
<ai-dialog-btn text="编辑" dialogTitle="编辑导航栏" width="600px">
<el-form-item label="名称">
<el-input v-model="row.text" placeholder="请输入" clearable/>
</el-form-item>
<el-form-item label="默认图标">
2022-11-08 18:33:05 +08:00
<el-input v-model="row.iconPath" placeholder="请输入" clearable/>
</el-form-item>
<el-form-item label="选中图标">
<el-input v-model="row.selectedIconPath" placeholder="请输入" clearable/>
</el-form-item>
</ai-dialog-btn>
<el-button type="text" @click="handleTabbarDelete($index)">删除</el-button>
</el-row>
2022-07-15 18:12:50 +08:00
</template>
</el-table-column>
</ai-table>
2022-07-14 10:11:17 +08:00
</template>
2022-08-08 11:06:32 +08:00
<template v-else-if="form.type=='wxwork'">
<el-row type="flex">
<div class="fill">
<el-form-item label="接口是否单服务">
<el-checkbox v-model="form.isSingleService"/>
</el-form-item>
2022-08-17 11:52:38 +08:00
<el-form-item label="是否启用水印">
<el-checkbox v-model="form.waterMarker"/>
</el-form-item>
</div>
<div class="fill">
<el-form-item label="默认首页">
<el-input v-model="form.homePage" clearable placeholder="填写应用的文件名"/>
</el-form-item>
2022-08-17 13:52:27 +08:00
<el-form-item label="开启百度流量">
2022-08-17 11:52:38 +08:00
<el-checkbox v-model="form.hmt"/>
</el-form-item>
</div>
</el-row>
2022-08-08 11:06:32 +08:00
</template>
2022-08-23 15:19:35 +08:00
<template v-else-if="form.type=='web'">
2022-08-24 17:50:15 +08:00
<el-form-item label="头部导航工具栏">
<el-checkbox v-model="form.downloadCenter">下载中心</el-checkbox>
<el-checkbox v-model="form.dv">数据大屏</el-checkbox>
<el-checkbox v-model="form.showTool">显示/隐藏导航栏</el-checkbox>
<el-checkbox v-model="form.helpDoc">帮助文档</el-checkbox>
<el-checkbox v-model="form.customerService">智能客服</el-checkbox>
2022-08-26 18:06:40 +08:00
<el-checkbox v-model="form.appQRCode">手机APP</el-checkbox>
2022-08-24 17:50:15 +08:00
</el-form-item>
2022-08-23 15:19:35 +08:00
<el-row type="flex">
<div class="fill">
<el-form-item label="接口是否单服务">
<el-checkbox v-model="form.isSingleService"/>
</el-form-item>
2022-08-24 13:44:19 +08:00
<el-form-item label="默认首页">
<el-input v-model="form.homePage" clearable placeholder="填写应用的文件名"/>
</el-form-item>
2022-08-23 15:19:35 +08:00
</div>
<div class="fill">
<el-form-item label="开启百度流量">
<el-checkbox v-model="form.hmt"/>
</el-form-item>
</div>
</el-row>
</template>
</template>
</ai-card>
</el-form>
</el-tab-pane>
<el-tab-pane label="方案应用" lazy>
2022-11-11 17:13:36 +08:00
<ai-lib-table :meta="appList" :isShowPagination="false" v-bind="$props" disabled :colConfigs="appListConfigs">
<template slot="options" slot-scope="{row}">
<ai-dialog-btn text="编辑" :customFooter="false" dialogTitle="应用配置" width="500px" @onConfirm="handleAppEdit(row)">
<el-form size="small" label-width="80px">
<el-form-item label="应用名称">
<el-input v-model="row.label" clearable placeholder="请输入应用名称"/>
</el-form-item>
</el-form>
</ai-dialog-btn>
</template>
</ai-lib-table>
</el-tab-pane>
</el-tabs>
2022-07-01 18:26:52 +08:00
</template>
<template #footer>
<el-button @click="back">取消</el-button>
<el-button type="primary" @click="submit">提交</el-button>
</template>
</ai-detail>
</section>
</template>
<script>
2022-07-04 14:16:07 +08:00
import AiLibTable from "./AiLibTable";
2022-07-01 18:26:52 +08:00
export default {
name: "add",
2022-07-04 14:16:07 +08:00
components: {AiLibTable},
2022-07-01 18:26:52 +08:00
props: {
instance: Function,
dict: Object,
permissions: Function
},
computed: {
isEdit: v => !!v.$route.query.id,
pageTitle: v => v.isEdit ? "编辑定制方案" : "新增定制方案",
appList() {
return this.form.appList?.map(e => {
e.category = e.libPath.replace(/^\/[^\/]+\/([^\/]+)\/.+/, '$1')
if (/\/project\//.test(e.libPath)) {
e.project = e.libPath.replace(/.*project\/([^\/]+)\/.+/, '$1')
} else if (/\/core\//.test(e.libPath)) {
e.project = "core"
} else e.project = "standard"
return e
2022-08-26 09:54:23 +08:00
}).filter(e => e.project != "core") || []
2022-07-14 10:11:17 +08:00
},
2022-07-01 18:26:52 +08:00
},
data() {
return {
2022-12-28 17:50:17 +08:00
form: {apps: [], type: null, sysInfo: {}, customPath: ""},
2022-07-01 18:26:52 +08:00
rules: {
name: {required: true, message: "请输入"},
type: {required: true, message: "请选择"},
2022-12-28 17:50:17 +08:00
// customPath: {required: true, message: "请输入"},
2022-07-01 18:26:52 +08:00
},
2022-07-14 10:11:17 +08:00
colConfigs: [
{prop: 'text', label: "名称"},
{prop: 'pagePath', label: "应用路径"},
{prop: 'iconPath', label: "默认图标"},
{prop: 'selectedIconPath', label: "选中图标"},
2022-07-14 12:01:12 +08:00
],
appListConfigs: [
{prop: 'label', label: "应用名称", render: (h, {row}) => h(row.tabbar ? 'b' : 'p', row.label + ` ${row.tabbar ? '(底部导航栏)' : ''}`)},
{prop: 'project', label: "项目/框架"},
{prop: 'category', label: "分类", dict: "appsCategory"},
{prop: 'name', label: "模块名"}
2022-07-15 18:12:50 +08:00
],
tabBar: {
color: "#666666",
selectedColor: "#197DF0",
backgroundColor: "#ffffff",
list: [
{pagePath: "pages/AppHome/AppHome", text: "首页", iconPath: "static/TabBar/home.png", selectedIconPath: "static/TabBar/home_selected.png"},
2022-07-15 19:03:58 +08:00
{pagePath: "pages/AppModules/AppModules", text: "应用", iconPath: "static/TabBar/service.png", selectedIconPath: "static/TabBar/service_selected.png"},
2022-07-15 18:12:50 +08:00
{
pagePath: "pages/AppEnteringVillage/AppEnteringVillage", text: "进村",
iconPath: "static/TabBar/custom.png", selectedIconPath: "static/TabBar/custom_selected.png"
},
2022-07-15 19:03:58 +08:00
{pagePath: "pages/AppMine/AppMine", text: "我的", iconPath: "static/TabBar/me.png", selectedIconPath: "static/TabBar/me_selected.png"}
2022-07-15 18:12:50 +08:00
]
}
2022-07-01 18:26:52 +08:00
}
},
methods: {
getDetail() {
let {id} = this.$route.query
id && this.instance.post("/node/custom/detail", null, {
params: {id}
}).then(res => {
if (res?.data) {
this.form = {...this.form, ...res.data}
2022-07-14 10:11:17 +08:00
this.handleSysTypeChange(this.form.type, this.form.extra)
2022-07-01 18:26:52 +08:00
}
})
},
back() {
this.$router.push({})
},
submit() {
this.$refs.AddForm.validate(v => {
if (v) {
const {
tabBar,
form: {type, appId, embeddedAppIdList, isSingleService, homePage, hmt, dv, downloadCenter, showTool, helpDoc, customerService, sysInfo, appQRCode}
} = this
2022-07-14 10:11:17 +08:00
if (type == 'mp') {
2022-11-02 17:51:48 +08:00
this.form.extra = {tabBar, appId, embeddedAppIdList, isSingleService}
2022-08-24 14:43:43 +08:00
} else if (type == 'web') {
2022-08-26 10:12:37 +08:00
const {desc} = sysInfo
sysInfo.desc = JSON.parse(desc || null)
2022-08-26 18:22:22 +08:00
this.form.extra = {isSingleService, homePage, hmt, dv, downloadCenter, showTool, helpDoc, customerService, sysInfo, appQRCode}
} else if (type == 'wxwork') {
2022-08-24 14:44:26 +08:00
this.form.extra = {isSingleService, homePage, hmt}
2022-07-14 10:11:17 +08:00
}
2022-07-01 18:26:52 +08:00
this.instance.post("/node/custom/addOrUpdate", this.form).then(res => {
if (res?.code == 0) {
this.$message.success("提交成功!")
this.getDetail()
2022-07-01 18:26:52 +08:00
}
})
}
})
},
2022-08-08 14:07:53 +08:00
handleSysTypeChange(v, data = {}) {
let values = this.$copy(data)
2022-07-14 10:11:17 +08:00
if (v == 'mp') {
2022-08-08 14:07:53 +08:00
if (values?.tabBar) {
this.tabBar = values.tabBar || this.tabBar
delete values.tabBar
}
2022-08-26 10:12:37 +08:00
} else if (v == 'web') {
if (values?.sysInfo?.desc) values.sysInfo.desc = JSON.stringify(values.sysInfo.desc)
2022-07-14 10:11:17 +08:00
}
2022-08-08 14:07:53 +08:00
Object.keys(values).map(e => this.$set(this.form, e, values[e]))
2022-07-15 18:12:50 +08:00
},
handleTabbarChange(row, {name, label}) {
2022-07-15 18:42:59 +08:00
row.text = label
2022-07-15 18:12:50 +08:00
row.pagePath = `pages/${name}/${name}`
},
handleTabbarDelete(i) {
this.tabBar.list?.splice(i, 1)
2022-11-11 17:13:36 +08:00
},
handleAppEdit(row) {
const i = this.form.appList.findIndex(e => e.id == row.id)
this.form.appList.splice(i, 1, row)
2022-07-14 10:11:17 +08:00
}
2022-07-01 18:26:52 +08:00
},
created() {
this.getDetail()
}
}
</script>
<style lang="scss" scoped>
.add {
height: 100%;
2022-07-04 14:48:21 +08:00
.mar-l16 {
margin-left: 16px;
2022-07-01 18:26:52 +08:00
}
}
</style>