| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 |
- import { readFileSync, writeFileSync } from 'node:fs';
- import path from 'node:path';
- import { fileURLToPath } from 'node:url';
- const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..');
- const srcPath = path.join(root, 'saas-companyui/src/views/company/companyVoiceRobotic/index.vue');
- const destPath = path.join(root, 'saas-mgnui/src/views/company/companyVoiceRobotic/index.vue');
- let content = readFileSync(srcPath, 'utf8');
- const companySearchForm = ` <el-form-item label="\u516C\u53F8" prop="companyId">
- <el-select
- v-model="queryParams.companyId"
- clearable
- filterable
- placeholder="\u5168\u90E8"
- size="small"
- @change="onQueryCompanyChange"
- >
- <el-option
- v-for="item in companys"
- :key="item.companyId"
- :label="item.companyName"
- :value="item.companyId"
- />
- </el-select>
- </el-form-item>
- `;
- const companyTableCol = ` <el-table-column label="\u516C\u53F8" align="center" min-width="120" show-overflow-tooltip>
- <template slot-scope="scope">{{ resolveCompanyName(scope.row.companyId) }}</template>
- </el-table-column>
- `;
- const companyFormItem = ` <el-form-item label="\u516C\u53F8" prop="companyId">
- <el-select
- v-model="form.companyId"
- filterable
- placeholder="\u8BF7\u9009\u62E9\u516C\u53F8"
- @change="onFormCompanyChange"
- >
- <el-option
- v-for="item in companys"
- :key="item.companyId"
- :label="item.companyName"
- :value="item.companyId"
- />
- </el-select>
- </el-form-item>
- `;
- content = content.replace(
- ' <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px" class="list-search-form">\n <el-form-item label="\u4EFB\u52A1\u540D\u79F0"',
- ` <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px" class="list-search-form">\n${companySearchForm} <el-form-item label="\u4EFB\u52A1\u540D\u79F0"`
- );
- content = content.replace(
- ' <el-table-column label="ID" align="center" prop="id"/>\n <el-table-column label="\u4EFB\u52A1\u540D\u79F0"',
- ` <el-table-column label="ID" align="center" prop="id"/>\n${companyTableCol} <el-table-column label="\u4EFB\u52A1\u540D\u79F0"`
- );
- content = content.replace(
- ' <el-form ref="form" :model="form" :rules="rules" label-width="90px" class="task-form">\n <div class="form-section" >',
- ` <el-form ref="form" :model="form" :rules="rules" label-width="90px" class="task-form">\n${companyFormItem} <div class="form-section" >`
- );
- content = content.replace(
- ` listRobotic,
- getRobotic,`,
- ` listRobotic,
- listAll,
- getRobotic,`
- );
- content = content.replace(
- ` getCurrentCompanyId,
- pauseRoboticActive,
- appendCustomers,
- listSmsDeviceOptions
- } from "@/api/company/companyVoiceRobotic";`,
- ` pauseRoboticActive,
- appendCustomers,
- listSmsDeviceOptions,
- companyUserList
- } from "@/api/company/companyVoiceRobotic";
- import companyScopeMixin from '@/views/company/mixins/companyScopeMixin'`
- );
- content = content.replace(
- 'export default {\n name: "Robotic",',
- 'export default {\n name: "Robotic",\n mixins: [companyScopeMixin],'
- );
- content = content.replace(
- ' currentCompanyId:null,\n workflowHasAddWx: false,',
- ' workflowHasAddWx: false,'
- );
- content = content.replace(
- ` queryParams: {
- pageNum: 1,
- pageSize: 10,
- name: null,`,
- ` queryParams: {
- pageNum: 1,
- pageSize: 10,
- companyId: null,
- name: null,`
- );
- content = content.replace(
- ` rules: {
- taskType:[`,
- ` rules: {
- companyId: [{ required: true, message: '\u8BF7\u9009\u62E9\u516C\u53F8', trigger: 'change' }],
- taskType:[`
- );
- content = content.replace(
- ` this.loadSmsDeviceOptions();
- getCurrentCompanyId().then(res=>{
- this.currentCompanyId = res.companyId;
- }).catch(res=>{
- console.log(res);
- })
- //getTypes().then(e => {
- //this.robotList = e.robot;
- //this.dialogList = e.dialog;
- //})
- // listAll().then(e => {
- // this.wxDialogList = e.data;
- // })
- companyUserList().then(e => {
- this.qwUserList = e.data;
- })
- optionList().then(e => {
- this.workflowList = e.data;
- })`,
- ` this.loadRoboticRelatedOptions()`
- );
- content = content.replace(
- ' methods: {\n\n getIntentionText(intention) {',
- ` computed: {
- activeCompanyId() {
- return this.form.companyId || this.queryParams.companyId || null
- }
- },
- methods: {
- loadRoboticRelatedOptions(companyId) {
- const params = companyId ? { companyId } : {}
- listAll(params).then(res => {
- this.robotList = res.data || []
- })
- optionList(params).then(res => {
- this.workflowList = res.data || []
- })
- },
- handleQueryCompanyChange() {
- this.loadRoboticRelatedOptions(this.queryParams.companyId)
- this.queryParams.pageNum = 1
- this.getList()
- },
- handleFormCompanyChange(companyId) {
- this.form.companyAiWorkflowId = null
- if (this.form.qwUser && this.form.qwUser.length) {
- this.form.qwUser.forEach(item => {
- item.companyUserId = []
- })
- }
- this.selectQwUserList = []
- optionList(companyId ? { companyId } : {}).then(res => {
- this.workflowList = res.data || []
- })
- this.loadFormCompanyUsers(companyId)
- this.loadSmsDeviceOptions(companyId)
- },
- loadFormCompanyUsers(companyId) {
- if (!companyId) {
- this.qwUserList = []
- return
- }
- companyUserList({ companyId }).then(res => {
- this.qwUserList = res.data || []
- })
- },
- getIntentionText(intention) {`
- );
- content = content.replace(
- ` loadSmsDeviceOptions() {
- listSmsDeviceOptions().then(res => {
- this.smsDeviceList = res.data || [];
- }).catch(() => {
- this.smsDeviceList = [];
- });
- },`,
- ` loadSmsDeviceOptions(companyId) {
- const cid = companyId || this.activeCompanyId
- const params = cid ? { companyId: cid } : {}
- listSmsDeviceOptions(params).then(res => {
- this.smsDeviceList = res.data || [];
- }).catch(() => {
- this.smsDeviceList = [];
- });
- },`
- );
- content = content.replace(
- ` handleAdd() {
- this.reset();
- this.loadSmsDeviceOptions();
- optionList().then(e => {
- this.workflowList = e.data;
- })
- this.open = true;
- this.title = "\u6DFB\u52A0\u4EFB\u52A1";
- },`,
- ` handleAdd() {
- this.reset();
- if (this.queryParams.companyId) {
- this.form.companyId = this.queryParams.companyId
- }
- this.loadRoboticRelatedOptions(this.form.companyId)
- this.loadSmsDeviceOptions(this.form.companyId);
- this.open = true;
- this.title = "\u6DFB\u52A0\u4EFB\u52A1";
- },`
- );
- content = content.replace(
- ` this.loadSmsDeviceOptions();
- if (this.form.companyAiWorkflowId) {
- this.onWorkflowChange(this.form.companyAiWorkflowId, true);
- }
- this.open = true;`,
- ` this.loadFormCompanyUsers(this.form.companyId)
- optionList(this.form.companyId ? { companyId: this.form.companyId } : {}).then(res => {
- this.workflowList = res.data || []
- })
- this.loadSmsDeviceOptions(this.form.companyId);
- if (this.form.companyAiWorkflowId) {
- this.onWorkflowChange(this.form.companyAiWorkflowId, true);
- }
- this.open = true;`
- );
- content = content.replace(
- ` this.form = {
- id: null,
- name: null,`,
- ` this.form = {
- id: null,
- companyId: null,
- name: null,`
- );
- content = content.replace(
- ` openSelect() {
- if(!!this.currentCompanyId){
- this.$refs.customer.setRowsDesignatedCompany(this.form.userTableList || [],this.currentCompanyId);`,
- ` openSelect() {
- if (!this.activeCompanyId) {
- this.msgError('\u8BF7\u5148\u9009\u62E9\u516C\u53F8');
- return;
- }
- this.$refs.customer.setRowsDesignatedCompany(this.form.userTableList || [], this.activeCompanyId);`
- );
- content = content.replace(/this\.currentCompanyId/g, 'this.activeCompanyId');
- content = content.replace(
- ` companyId: (currentTask && currentTask.companyId) || null,`,
- ` companyId: (currentTask && currentTask.companyId) || this.activeCompanyId || null,`
- );
- writeFileSync(destPath, content, 'utf8');
- console.log('Synced admin index.vue from companyui:', destPath);
|