sync_voice_robotic_index_from_company.mjs 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. import { readFileSync, writeFileSync } from 'node:fs';
  2. import path from 'node:path';
  3. import { fileURLToPath } from 'node:url';
  4. const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..');
  5. const srcPath = path.join(root, 'saas-companyui/src/views/company/companyVoiceRobotic/index.vue');
  6. const destPath = path.join(root, 'saas-mgnui/src/views/company/companyVoiceRobotic/index.vue');
  7. let content = readFileSync(srcPath, 'utf8');
  8. const companySearchForm = ` <el-form-item label="\u516C\u53F8" prop="companyId">
  9. <el-select
  10. v-model="queryParams.companyId"
  11. clearable
  12. filterable
  13. placeholder="\u5168\u90E8"
  14. size="small"
  15. @change="onQueryCompanyChange"
  16. >
  17. <el-option
  18. v-for="item in companys"
  19. :key="item.companyId"
  20. :label="item.companyName"
  21. :value="item.companyId"
  22. />
  23. </el-select>
  24. </el-form-item>
  25. `;
  26. const companyTableCol = ` <el-table-column label="\u516C\u53F8" align="center" min-width="120" show-overflow-tooltip>
  27. <template slot-scope="scope">{{ resolveCompanyName(scope.row.companyId) }}</template>
  28. </el-table-column>
  29. `;
  30. const companyFormItem = ` <el-form-item label="\u516C\u53F8" prop="companyId">
  31. <el-select
  32. v-model="form.companyId"
  33. filterable
  34. placeholder="\u8BF7\u9009\u62E9\u516C\u53F8"
  35. @change="onFormCompanyChange"
  36. >
  37. <el-option
  38. v-for="item in companys"
  39. :key="item.companyId"
  40. :label="item.companyName"
  41. :value="item.companyId"
  42. />
  43. </el-select>
  44. </el-form-item>
  45. `;
  46. content = content.replace(
  47. ' <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"',
  48. ` <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"`
  49. );
  50. content = content.replace(
  51. ' <el-table-column label="ID" align="center" prop="id"/>\n <el-table-column label="\u4EFB\u52A1\u540D\u79F0"',
  52. ` <el-table-column label="ID" align="center" prop="id"/>\n${companyTableCol} <el-table-column label="\u4EFB\u52A1\u540D\u79F0"`
  53. );
  54. content = content.replace(
  55. ' <el-form ref="form" :model="form" :rules="rules" label-width="90px" class="task-form">\n <div class="form-section" >',
  56. ` <el-form ref="form" :model="form" :rules="rules" label-width="90px" class="task-form">\n${companyFormItem} <div class="form-section" >`
  57. );
  58. content = content.replace(
  59. ` listRobotic,
  60. getRobotic,`,
  61. ` listRobotic,
  62. listAll,
  63. getRobotic,`
  64. );
  65. content = content.replace(
  66. ` getCurrentCompanyId,
  67. pauseRoboticActive,
  68. appendCustomers,
  69. listSmsDeviceOptions
  70. } from "@/api/company/companyVoiceRobotic";`,
  71. ` pauseRoboticActive,
  72. appendCustomers,
  73. listSmsDeviceOptions,
  74. companyUserList
  75. } from "@/api/company/companyVoiceRobotic";
  76. import companyScopeMixin from '@/views/company/mixins/companyScopeMixin'`
  77. );
  78. content = content.replace(
  79. 'export default {\n name: "Robotic",',
  80. 'export default {\n name: "Robotic",\n mixins: [companyScopeMixin],'
  81. );
  82. content = content.replace(
  83. ' currentCompanyId:null,\n workflowHasAddWx: false,',
  84. ' workflowHasAddWx: false,'
  85. );
  86. content = content.replace(
  87. ` queryParams: {
  88. pageNum: 1,
  89. pageSize: 10,
  90. name: null,`,
  91. ` queryParams: {
  92. pageNum: 1,
  93. pageSize: 10,
  94. companyId: null,
  95. name: null,`
  96. );
  97. content = content.replace(
  98. ` rules: {
  99. taskType:[`,
  100. ` rules: {
  101. companyId: [{ required: true, message: '\u8BF7\u9009\u62E9\u516C\u53F8', trigger: 'change' }],
  102. taskType:[`
  103. );
  104. content = content.replace(
  105. ` this.loadSmsDeviceOptions();
  106. getCurrentCompanyId().then(res=>{
  107. this.currentCompanyId = res.companyId;
  108. }).catch(res=>{
  109. console.log(res);
  110. })
  111. //getTypes().then(e => {
  112. //this.robotList = e.robot;
  113. //this.dialogList = e.dialog;
  114. //})
  115. // listAll().then(e => {
  116. // this.wxDialogList = e.data;
  117. // })
  118. companyUserList().then(e => {
  119. this.qwUserList = e.data;
  120. })
  121. optionList().then(e => {
  122. this.workflowList = e.data;
  123. })`,
  124. ` this.loadRoboticRelatedOptions()`
  125. );
  126. content = content.replace(
  127. ' methods: {\n\n getIntentionText(intention) {',
  128. ` computed: {
  129. activeCompanyId() {
  130. return this.form.companyId || this.queryParams.companyId || null
  131. }
  132. },
  133. methods: {
  134. loadRoboticRelatedOptions(companyId) {
  135. const params = companyId ? { companyId } : {}
  136. listAll(params).then(res => {
  137. this.robotList = res.data || []
  138. })
  139. optionList(params).then(res => {
  140. this.workflowList = res.data || []
  141. })
  142. },
  143. handleQueryCompanyChange() {
  144. this.loadRoboticRelatedOptions(this.queryParams.companyId)
  145. this.queryParams.pageNum = 1
  146. this.getList()
  147. },
  148. handleFormCompanyChange(companyId) {
  149. this.form.companyAiWorkflowId = null
  150. if (this.form.qwUser && this.form.qwUser.length) {
  151. this.form.qwUser.forEach(item => {
  152. item.companyUserId = []
  153. })
  154. }
  155. this.selectQwUserList = []
  156. optionList(companyId ? { companyId } : {}).then(res => {
  157. this.workflowList = res.data || []
  158. })
  159. this.loadFormCompanyUsers(companyId)
  160. this.loadSmsDeviceOptions(companyId)
  161. },
  162. loadFormCompanyUsers(companyId) {
  163. if (!companyId) {
  164. this.qwUserList = []
  165. return
  166. }
  167. companyUserList({ companyId }).then(res => {
  168. this.qwUserList = res.data || []
  169. })
  170. },
  171. getIntentionText(intention) {`
  172. );
  173. content = content.replace(
  174. ` loadSmsDeviceOptions() {
  175. listSmsDeviceOptions().then(res => {
  176. this.smsDeviceList = res.data || [];
  177. }).catch(() => {
  178. this.smsDeviceList = [];
  179. });
  180. },`,
  181. ` loadSmsDeviceOptions(companyId) {
  182. const cid = companyId || this.activeCompanyId
  183. const params = cid ? { companyId: cid } : {}
  184. listSmsDeviceOptions(params).then(res => {
  185. this.smsDeviceList = res.data || [];
  186. }).catch(() => {
  187. this.smsDeviceList = [];
  188. });
  189. },`
  190. );
  191. content = content.replace(
  192. ` handleAdd() {
  193. this.reset();
  194. this.loadSmsDeviceOptions();
  195. optionList().then(e => {
  196. this.workflowList = e.data;
  197. })
  198. this.open = true;
  199. this.title = "\u6DFB\u52A0\u4EFB\u52A1";
  200. },`,
  201. ` handleAdd() {
  202. this.reset();
  203. if (this.queryParams.companyId) {
  204. this.form.companyId = this.queryParams.companyId
  205. }
  206. this.loadRoboticRelatedOptions(this.form.companyId)
  207. this.loadSmsDeviceOptions(this.form.companyId);
  208. this.open = true;
  209. this.title = "\u6DFB\u52A0\u4EFB\u52A1";
  210. },`
  211. );
  212. content = content.replace(
  213. ` this.loadSmsDeviceOptions();
  214. if (this.form.companyAiWorkflowId) {
  215. this.onWorkflowChange(this.form.companyAiWorkflowId, true);
  216. }
  217. this.open = true;`,
  218. ` this.loadFormCompanyUsers(this.form.companyId)
  219. optionList(this.form.companyId ? { companyId: this.form.companyId } : {}).then(res => {
  220. this.workflowList = res.data || []
  221. })
  222. this.loadSmsDeviceOptions(this.form.companyId);
  223. if (this.form.companyAiWorkflowId) {
  224. this.onWorkflowChange(this.form.companyAiWorkflowId, true);
  225. }
  226. this.open = true;`
  227. );
  228. content = content.replace(
  229. ` this.form = {
  230. id: null,
  231. name: null,`,
  232. ` this.form = {
  233. id: null,
  234. companyId: null,
  235. name: null,`
  236. );
  237. content = content.replace(
  238. ` openSelect() {
  239. if(!!this.currentCompanyId){
  240. this.$refs.customer.setRowsDesignatedCompany(this.form.userTableList || [],this.currentCompanyId);`,
  241. ` openSelect() {
  242. if (!this.activeCompanyId) {
  243. this.msgError('\u8BF7\u5148\u9009\u62E9\u516C\u53F8');
  244. return;
  245. }
  246. this.$refs.customer.setRowsDesignatedCompany(this.form.userTableList || [], this.activeCompanyId);`
  247. );
  248. content = content.replace(/this\.currentCompanyId/g, 'this.activeCompanyId');
  249. content = content.replace(
  250. ` companyId: (currentTask && currentTask.companyId) || null,`,
  251. ` companyId: (currentTask && currentTask.companyId) || this.activeCompanyId || null,`
  252. );
  253. writeFileSync(destPath, content, 'utf8');
  254. console.log('Synced admin index.vue from companyui:', destPath);