| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278 |
- import fs from 'fs'
- import path from 'path'
- import { fileURLToPath } from 'url'
- const __dirname = path.dirname(fileURLToPath(import.meta.url))
- const root = path.resolve(__dirname, '../..')
- const srcVue = path.join(root, 'saas-companyui/src/views/company/companyWorkflow/design.vue')
- const dstVue = path.join(root, 'saas-mgnui/src/views/company/companyWorkflow/design.vue')
- const srcScss = path.join(root, 'saas-companyui/src/views/company/companyWorkflow/design.scss')
- const dstScss = path.join(root, 'saas-mgnui/src/views/company/companyWorkflow/design.scss')
- let vue = fs.readFileSync(srcVue, 'utf8')
- fs.copyFileSync(srcScss, dstScss)
- // toolbar: company + sales selectors
- vue = vue.replace(
- ` <el-select v-model="form.workflowType" placeholder="类型" size="small" style="width: 120px; margin-left: 10px">
- <el-option
- v-for="dict in workflowTypeOptions"
- :key="dict.dictValue"
- :label="dict.dictLabel"
- :value="dict.dictValue"
- />
- </el-select>
- </div>`,
- ` <el-select v-model="form.workflowType" placeholder="类型" size="small" style="width: 120px; margin-left: 10px">
- <el-option
- v-for="dict in workflowTypeOptions"
- :key="dict.dictValue"
- :label="dict.dictLabel"
- :value="dict.dictValue"
- />
- </el-select>
- <el-select
- v-if="!readonlyMode"
- v-model="formCompanyId"
- placeholder="选择公司"
- size="small"
- style="width: 160px; margin-left: 10px"
- filterable
- :disabled="!!workflowId"
- @change="onDesignCompanyChange"
- >
- <el-option
- v-for="item in companys"
- :key="item.companyId"
- :label="item.companyName"
- :value="item.companyId"
- />
- </el-select>
- <el-select
- v-if="!readonlyMode && !workflowId"
- v-model="formCompanyUserId"
- placeholder="销售人员"
- size="small"
- style="width: 140px; margin-left: 10px"
- filterable
- clearable
- :disabled="!formCompanyId"
- >
- <el-option
- v-for="item in formSalesUserOptions"
- :key="item.userId"
- :label="item.nickName || item.userName"
- :value="item.userId"
- />
- </el-select>
- </div>`
- )
- // imports + mixin
- vue = vue.replace(
- `import { listAll } from '@/api/company/wxDialog';
- export default {
- name: 'WorkflowDesign',`,
- `import { listAll } from '@/api/company/wxDialog'
- import companyScopeMixin from '@/views/company/mixins/companyScopeMixin'
- import { getUserList } from '@/api/company/companyUser'
- export default {
- name: 'WorkflowDesign',
- mixins: [companyScopeMixin],`
- )
- // data fields
- vue = vue.replace(
- ` // 工作流ID
- workflowId: null,
- // 历史版本ID`,
- ` // 工作流ID
- workflowId: null,
- // 总后台:绑定公司与销售人员
- formCompanyId: null,
- formCompanyUserId: null,
- formSalesUserOptions: [],
- // 历史版本ID`
- )
- // created: route companyId + scoped options
- vue = vue.replace(
- ` created() {
- this.workflowId = this.$route.params.id
- this.versionId = this.$route.params.versionId`,
- ` created() {
- this.workflowId = this.$route.params.id
- this.versionId = this.$route.params.versionId
- const routeCompanyId = this.$route.query.companyId
- if (routeCompanyId) {
- this.formCompanyId = Number(routeCompanyId)
- }`
- )
- vue = vue.replace(
- ` listAll().then(e => {
- this.wxDialogList = e.data;
- console.log("------")
- console.log(this.wxDialogList)
- })`,
- ` this.loadWxDialogList()
- if (this.formCompanyId) {
- this.onDesignCompanyChange(this.formCompanyId)
- }`
- )
- vue = vue.replace(
- ` // 预加载转人工分机列表(用于保存时ID→完整信息映射)
- getExtensionList().then(res => {
- this.easyCallExtensionList = (res.data || []).map(item => ({
- ...item,
- _label: item.companyUserName ? \`\${item.extensionNum}-\${item.companyUserName}\` : item.extensionNum
- }))
- })`,
- ` // 预加载转人工分机列表(用于保存时ID→完整信息映射)
- this.loadExtensionList()`
- )
- // selectNode easyCall + sms with companyId
- vue = vue.replace(/getGatewayList\(\)/g, 'getGatewayList(this.resolveDesignCompanyParams())')
- vue = vue.replace(/getLlmAccountList\(\)/g, 'getLlmAccountList(this.resolveDesignCompanyParams())')
- vue = vue.replace(/getVoiceCodeList\(\)/g, 'getVoiceCodeList(this.resolveDesignCompanyParams())')
- vue = vue.replace(/getBusiGroupList\(\)/g, 'getBusiGroupList(this.resolveDesignCompanyParams())')
- vue = vue.replace(
- ` // 刷新分机列表(预加载已在created完成,此处刷新最新数据)
- getExtensionList(this.resolveDesignCompanyParams()).then(res => {
- this.easyCallExtensionList = (res.data || []).map(item => ({
- ...item,
- _label: item.companyUserName ? \`\${item.extensionNum}-\${item.companyUserName}\` : item.extensionNum
- }))
- })`,
- ` this.loadExtensionList()`
- )
- vue = vue.replace(
- ` getSmsTempList().then(res => {
- this.smsTempList = res.data || []
- })`,
- ` getSmsTempList(this.resolveDesignCompanyParams()).then(res => {
- this.smsTempList = res.data || []
- })`
- )
- // loadWorkflow: set company from data
- vue = vue.replace(
- ` loadWorkflow() {
- getWorkflow(this.workflowId).then(res => {
- const data = res.data
- this.form = {`,
- ` loadWorkflow() {
- getWorkflow(this.workflowId).then(res => {
- const data = res.data
- if (data.companyId) {
- this.formCompanyId = data.companyId
- this.onDesignCompanyChange(data.companyId)
- }
- if (data.companyUserId) {
- this.formCompanyUserId = data.companyUserId
- }
- this.form = {`
- )
- // handleSave: validate + company fields
- vue = vue.replace(
- ` if (!this.form.workflowName) {
- this.$message.warning('请输入工作流名称')
- return
- }
- if (!this.form.workflowName) {
- this.$message.warning('请输入工作流名称')
- return
- }`,
- ` if (!this.form.workflowName) {
- this.$message.warning('请输入工作流名称')
- return
- }
- if (!this.formCompanyId) {
- this.$message.warning('请选择公司')
- return
- }
- if (!this.workflowId && !this.formCompanyUserId) {
- this.$message.warning('请选择销售人员')
- return
- }`
- )
- vue = vue.replace(
- ` startNodeKey: startNodes[0].nodeKey,
- endNodeKey: endNodes[0].nodeKey
- }`,
- ` startNodeKey: startNodes[0].nodeKey,
- endNodeKey: endNodes[0].nodeKey,
- companyId: this.formCompanyId,
- companyUserId: this.formCompanyUserId
- }`
- )
- vue = vue.replace(
- ` this.$router.replace('/companyWx/companyWorkflow/design/' + this.workflowId)`,
- ` this.$router.replace({
- path: '/companyWx/companyWorkflow/design/' + this.workflowId,
- query: { companyId: this.formCompanyId }
- })`
- )
- // admin helper methods
- const adminMethods = `
- resolveDesignCompanyParams() {
- return this.formCompanyId ? { companyId: this.formCompanyId } : {}
- },
- onDesignCompanyChange(companyId) {
- this.formCompanyUserId = null
- this.loadDesignSalesUsers(companyId)
- this.loadWxDialogList()
- this.loadExtensionList()
- },
- loadDesignSalesUsers(companyId) {
- if (!companyId) {
- this.formSalesUserOptions = []
- return
- }
- getUserList(companyId).then(res => {
- this.formSalesUserOptions = res.data || []
- })
- },
- loadWxDialogList() {
- const params = this.resolveDesignCompanyParams()
- if (!params.companyId) {
- this.wxDialogList = []
- return
- }
- listAll(params).then(e => {
- this.wxDialogList = e.data || []
- })
- },
- loadExtensionList() {
- const params = this.resolveDesignCompanyParams()
- if (!params.companyId) {
- this.easyCallExtensionList = []
- return
- }
- getExtensionList(params).then(res => {
- this.easyCallExtensionList = (res.data || []).map(item => ({
- ...item,
- _label: item.companyUserName ? \`\${item.extensionNum}-\${item.companyUserName}\` : item.extensionNum
- }))
- })
- },`
- vue = vue.replace(
- ` methods: {
- // 聚焦画布容器
- focusCanvasContainer() {`,
- ` methods: {${adminMethods}
- // 聚焦画布容器
- focusCanvasContainer() {`
- )
- fs.writeFileSync(dstVue, vue, 'utf8')
- console.log('Synced design.vue and design.scss to saas-mgnui')
|