scriptManage.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011
  1. <template>
  2. <div class="app-container">
  3. <el-form
  4. :model="queryParams"
  5. ref="queryForm"
  6. size="small"
  7. :inline="true"
  8. v-show="showSearch"
  9. label-width="88px"
  10. >
  11. <el-form-item :label="$t('script.scriptKey')" prop="scriptKey">
  12. <el-input
  13. v-model="queryParams.scriptKey"
  14. :placeholder="$t('script.pleaseEnterScriptKey')"
  15. clearable
  16. @keyup.enter.native="handleQuery"
  17. />
  18. </el-form-item>
  19. <!-- <el-form-item label="脚本方法名称" prop="scriptFunctionName">
  20. <el-input
  21. v-model="queryParams.scriptFunctionName"
  22. placeholder="请输入脚本方法名称"
  23. clearable
  24. @keyup.enter.native="handleQuery"
  25. />
  26. </el-form-item> -->
  27. <el-form-item :label="$t('script.scriptName')" prop="scriptName">
  28. <el-input
  29. v-model="queryParams.scriptName"
  30. :placeholder="$t('script.pleaseEnterScriptName')"
  31. clearable
  32. @keyup.enter.native="handleQuery"
  33. />
  34. </el-form-item>
  35. <el-form-item :label="$t('script.scriptType')" prop="scriptType">
  36. <el-select
  37. v-model="queryParams.scriptType"
  38. :placeholder="$t('script.pleaseSelectScriptType')"
  39. filterable
  40. clearable
  41. >
  42. <el-option
  43. v-for="item in dict.type.bpm_script_type"
  44. :key="item.value"
  45. :label="item.label"
  46. :value="item.value"
  47. >
  48. </el-option>
  49. </el-select>
  50. </el-form-item>
  51. <el-form-item :label="$t('script.industryType')" prop="industryType">
  52. <el-select
  53. v-model="queryParams.industryType"
  54. :placeholder="$t('script.pleaseSelectIndustryType')"
  55. filterable
  56. clearable
  57. >
  58. <el-option
  59. v-for="item in dict.type.industry_type"
  60. :key="item.value"
  61. :label="item.label"
  62. :value="item.value"
  63. >
  64. </el-option>
  65. </el-select>
  66. </el-form-item>
  67. <el-form-item :label="$t('tenant.tenant')" prop="tenantId">
  68. <el-select
  69. v-model="queryParams.tenantId"
  70. :placeholder="$t('script.pleaseSelectTenant')"
  71. filterable
  72. clearable
  73. >
  74. <el-option
  75. v-for="item in TenantAllList"
  76. :key="item.tenantId"
  77. :label="item.tenantName"
  78. :value="item.tenantId"
  79. >
  80. </el-option>
  81. </el-select>
  82. </el-form-item>
  83. <!-- <el-form-item label="数据表" prop="tableName">-->
  84. <!-- <el-input-->
  85. <!-- v-model="queryParams.tableName"-->
  86. <!-- placeholder="请输入数据表"-->
  87. <!-- clearable-->
  88. <!-- @keyup.enter.native="handleQuery"-->
  89. <!-- />-->
  90. <!-- </el-form-item>-->
  91. <el-form-item>
  92. <el-button
  93. type="primary"
  94. icon="el-icon-search"
  95. size="mini"
  96. @click="handleQuery"
  97. >{{ $t('normal.search') }}
  98. </el-button>
  99. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
  100. >{{ $t('normal.reset') }}
  101. </el-button>
  102. </el-form-item>
  103. </el-form>
  104. <el-row :gutter="10" class="mb8">
  105. <el-col :span="1.5">
  106. <el-button
  107. type="primary"
  108. plain
  109. icon="el-icon-plus"
  110. size="mini"
  111. @click="handleAdd"
  112. v-hasPermi="['system:script:add']"
  113. >{{ $t('normal.insert') }}
  114. </el-button>
  115. </el-col>
  116. <el-col :span="1.5">
  117. <el-button
  118. type="danger"
  119. plain
  120. icon="el-icon-delete"
  121. size="mini"
  122. :disabled="multiple"
  123. @click="handleDelete"
  124. v-hasPermi="['system:script:remove']"
  125. >{{ $t('normal.delete') }}
  126. </el-button>
  127. </el-col>
  128. <el-col :span="1.5">
  129. <el-button
  130. type="danger"
  131. plain
  132. icon="el-icon-download"
  133. size="mini"
  134. :disabled="multiple"
  135. @click="downloadTheNodeTemplate"
  136. v-hasPermi="['system:script:remove']"
  137. >{{ $t('script.downloadNodeTemplate') }}
  138. </el-button>
  139. </el-col>
  140. <el-col :span="1.5">
  141. <el-button
  142. type="danger"
  143. plain
  144. icon="el-icon-download"
  145. size="mini"
  146. @click="uploadTheNodeTemplate"
  147. v-hasPermi="['system:script:remove']"
  148. >{{ $t('script.uploadScriptFile') }}
  149. </el-button>
  150. </el-col>
  151. <!-- <el-col :span="1.5">
  152. <el-button
  153. type="success"
  154. plain
  155. icon="el-icon-edit"
  156. size="mini"
  157. :disabled="single"
  158. @click="handleUpdate"
  159. v-hasPermi="['system:script:edit']"
  160. >修改</el-button
  161. >
  162. </el-col> -->
  163. <!-- <el-col :span="1.5">
  164. <el-button
  165. type="warning"
  166. plain
  167. icon="el-icon-download"
  168. size="mini"
  169. @click="handleExport"
  170. v-hasPermi="['system:script:export']"
  171. >导出</el-button
  172. >
  173. </el-col> -->
  174. <right-toolbar
  175. :showSearch.sync="showSearch"
  176. @queryTable="getList"
  177. ></right-toolbar>
  178. </el-row>
  179. <el-table
  180. v-loading="loading"
  181. :data="scriptList"
  182. @selection-change="handleSelectionChange"
  183. style="margin-top: 20px"
  184. >
  185. <el-table-column type="selection" width="55" align="center" />
  186. <!--<el-table-column label="编号" align="center" prop="id" />-->
  187. <el-table-column :label="$t('script.scriptKey')" align="center" prop="scriptKey" />
  188. <!-- <el-table-column label="脚本方法名称" align="center" prop="scriptFunctionName" /> -->
  189. <el-table-column :label="$t('script.scriptName')" align="center" prop="scriptName" />
  190. <!-- <el-table-column
  191. label="脚本方法体"
  192. align="center"
  193. prop="scriptFunctionCode"
  194. /> -->
  195. <el-table-column :label="$t('script.scriptType')" align="center" prop="scriptType">
  196. <template slot-scope="scope">
  197. {{ getDictLabel(scope.row.scriptType, dict.type.bpm_script_type) }}
  198. </template>
  199. </el-table-column>
  200. <el-table-column :label="$t('script.industryType')" align="center" prop="industryType">
  201. <template slot-scope="scope">
  202. {{ getDictLabel(scope.row.industryType, dict.type.industry_type) }}
  203. </template>
  204. </el-table-column>
  205. <el-table-column :label="$t('script.scriptState')" align="center" prop="scriptState">
  206. <template slot-scope="scope">
  207. {{ getDictLabel(scope.row.scriptState, dict.type.zkqy_jbzt) }}
  208. </template>
  209. </el-table-column>
  210. <el-table-column :label="$t('script.componentState')" align="center" prop="pageUpload">
  211. <template slot-scope="scope">
  212. {{ getDictLabel(scope.row.pageUpload, dict.type.isuploadpage) }}
  213. </template>
  214. </el-table-column>
  215. <el-table-column
  216. :label="$t('script.scriptDescription')"
  217. align="center"
  218. prop="scriptDescription"
  219. />
  220. <el-table-column
  221. :label="$t('normal.operation')"
  222. align="center"
  223. class-name="small-padding fixed-width"
  224. >
  225. <template
  226. slot-scope="scope"
  227. v-if="
  228. $store.state.user.tenant.tenantId == scope.row.tenantId ||
  229. $store.state.user.userId == 1
  230. "
  231. >
  232. <el-dropdown>
  233. <el-button type="warning" plain size="small">
  234. {{ $t('normal.process') }}<i class="el-icon-arrow-down el-icon--right"></i>
  235. </el-button>
  236. <el-dropdown-menu slot="dropdown">
  237. <el-dropdown-item>
  238. <el-button
  239. size="mini"
  240. type="text"
  241. icon="el-icon-edit"
  242. @click="handleUpdate(scope.row)"
  243. v-hasPermi="['system:script:edit']"
  244. >{{ $t('update') }}
  245. </el-button>
  246. </el-dropdown-item>
  247. <el-dropdown-item>
  248. <el-button
  249. size="mini"
  250. type="text"
  251. icon="el-icon-delete"
  252. @click="handleDelete(scope.row)"
  253. v-hasPermi="['system:script:remove']"
  254. >{{ $t('normal.delete') }}
  255. </el-button>
  256. </el-dropdown-item>
  257. <el-dropdown-item v-if="$store.state.user.userId == 1">
  258. <el-button
  259. size="mini"
  260. type="text"
  261. icon="el-icon-edit"
  262. @click="examine(scope.row)"
  263. v-hasPermi="['system:script:edit']"
  264. >{{ $t('script.examine') }}
  265. </el-button>
  266. </el-dropdown-item>
  267. <el-dropdown-item >
  268. <el-button
  269. size="mini"
  270. type="text"
  271. icon="el-icon-edit"
  272. @click="updateLoadPage(scope.row)"
  273. v-hasPermi="['system:script:edit']"
  274. >{{ $t('script.uploadComponentPage') }}
  275. </el-button>
  276. </el-dropdown-item>
  277. </el-dropdown-menu>
  278. </el-dropdown>
  279. </template>
  280. </el-table-column>
  281. </el-table>
  282. <pagination
  283. v-show="total > 0"
  284. :total="total"
  285. :page.sync="queryParams.pageNum"
  286. :limit.sync="queryParams.pageSize"
  287. @pagination="getList"
  288. />
  289. <!-- 添加或修改流程节点脚本对话框 -->
  290. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  291. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  292. <el-form-item :label="$t('script.scriptKey')" prop="scriptKey">
  293. <el-col :span="20">
  294. <el-input
  295. v-model="form.scriptKey"
  296. :placeholder="$t('script.pleaseEnterScriptKey')"
  297. :disabled="true"
  298. />
  299. </el-col>
  300. <el-col :span="4">
  301. <el-button
  302. icon="el-icon-document-copy"
  303. v-clipboard:copy="form.scriptKey"
  304. v-clipboard:success="onCopy"
  305. v-clipboard:error="onError"
  306. ></el-button>
  307. </el-col>
  308. </el-form-item>
  309. <el-form-item :label="$t('script.scriptName')" prop="scriptName">
  310. <el-input v-model="form.scriptName" :placeholder="$t('script.pleaseEnterScriptName')" />
  311. </el-form-item>
  312. <el-form-item :label="$t('script.scriptType')" prop="scriptType">
  313. <!-- <el-input v-model="form.scriptName" placeholder="请输入脚本名称" /> -->
  314. <el-select
  315. v-model="form.scriptType"
  316. :placeholder="$t('script.pleaseSelectScriptType')"
  317. filterable
  318. >
  319. <el-option
  320. v-for="item in dict.type.bpm_script_type"
  321. :key="item.value"
  322. :label="item.label"
  323. :value="item.value"
  324. >
  325. </el-option>
  326. </el-select>
  327. </el-form-item>
  328. <el-form-item :label="$t('script.industryType')" prop="industryType">
  329. <el-select
  330. v-model="form.industryType"
  331. :placeholder="$t('script.pleaseSelectIndustryType')"
  332. filterable
  333. >
  334. <el-option
  335. v-for="item in dict.type.industry_type"
  336. :key="item.value"
  337. :label="item.label"
  338. :value="item.value"
  339. >
  340. </el-option>
  341. </el-select>
  342. </el-form-item>
  343. <!-- <el-form-item label="方法名:" prop="scriptFunctionName">-->
  344. <!-- <el-input-->
  345. <!-- v-model="form.scriptFunctionName"-->
  346. <!-- placeholder="请输入脚本方法名称"-->
  347. <!-- />-->
  348. <!-- </el-form-item>-->
  349. <!-- <el-form-item label="方法体:" prop="scriptFunctionCode">-->
  350. <!-- <el-input-->
  351. <!-- v-model="form.scriptFunctionCode"-->
  352. <!-- type="textarea"-->
  353. <!-- placeholder="请输入内容"-->
  354. <!-- />-->
  355. <!-- <div ref="container" class="monaco-container">-->
  356. <!-- </div>-->
  357. <!-- <el-button icon="el-icon-edit" @click="drawerOpenHandler"></el-button>-->
  358. <!-- </el-form-item>-->
  359. <el-form-item
  360. v-show="form.scriptType != '2'"
  361. :label="$t('script.tableName')"
  362. prop="tableName"
  363. >
  364. <el-select
  365. v-model="form.tableName"
  366. multiple
  367. :placeholder="$t('script.pleaseSelectTable')"
  368. >
  369. <el-option
  370. v-for="item in tableNameList"
  371. :key="item.tableName"
  372. :label="item.tableComment"
  373. :value="item.tableName"
  374. >
  375. </el-option>
  376. </el-select>
  377. </el-form-item>
  378. <el-form-item :label="$t('script.scriptDescription')" prop="scriptDescription">
  379. <el-input
  380. v-model="form.scriptDescription"
  381. :placeholder="$t('script.pleaseEnterScriptDescription')"
  382. />
  383. </el-form-item>
  384. </el-form>
  385. <div slot="footer" class="dialog-footer">
  386. <el-button type="primary" @click="submitForm">{{ $t('normal.confirm') }}</el-button>
  387. <el-button @click="cancel">{{ $t('normal.cancel') }}</el-button>
  388. </div>
  389. </el-dialog>
  390. <!-- 审核脚本表单 -->
  391. <el-dialog :title="title" :visible.sync="openSH" width="500px" append-to-body>
  392. <el-form ref="form1" :model="form" :rules="rules" label-width="100px">
  393. <el-form-item :label="$t('script.examineState')" prop="scriptState">
  394. <el-radio-group v-model="form.scriptState">
  395. <el-radio label="1">{{ $t('script.pass') }}</el-radio>
  396. <el-radio label="2">{{ $t('script.notPass') }}</el-radio>
  397. </el-radio-group>
  398. </el-form-item>
  399. <el-form-item :label="$t('normal.operation')" prop="scriptState">
  400. <el-button type="success" @click="xzcheck">{{ $t('script.downloadScript') }}</el-button>
  401. </el-form-item>
  402. </el-form>
  403. <div slot="footer" class="dialog-footer">
  404. <el-button type="primary" @click="submitForm2">{{ $t('normal.confirm') }}</el-button>
  405. <el-button @click="cancel1">{{ $t('normal.cancel') }}</el-button>
  406. </div>
  407. </el-dialog>
  408. <el-drawer
  409. :visible.sync="drawer"
  410. direction="rtl"
  411. :before-close="drawerHandleClose"
  412. :with-header="false"
  413. >
  414. <div ref="container" class="monaco-container"></div>
  415. </el-drawer>
  416. <!--节点上传 -->
  417. <el-dialog
  418. :title="upload.title"
  419. :visible.sync="upload.open"
  420. width="400px"
  421. append-to-body
  422. >
  423. <el-upload
  424. ref="upload"
  425. :limit="1"
  426. accept="*"
  427. :headers="upload.headers"
  428. :action="upload.url"
  429. :disabled="upload.isUploading"
  430. :on-progress="handleFileUploadProgress"
  431. :on-success="handleFileSuccess"
  432. :auto-upload="false"
  433. drag
  434. >
  435. <i class="el-icon-upload"></i>
  436. <div class="el-upload__text">{{ $t('script.uploadTip') }}</div>
  437. </el-upload>
  438. <div slot="footer" class="dialog-footer">
  439. <el-button type="primary" @click="submitFileForm">{{ $t('normal.confirm') }}</el-button>
  440. <el-button @click="upload.open = false">{{ $t('normal.cancel') }}</el-button>
  441. </div>
  442. </el-dialog>
  443. <!--页面上传 -->
  444. <el-dialog
  445. :title="upload1.title"
  446. :visible.sync="upload1.open"
  447. width="400px"
  448. append-to-body
  449. >
  450. <el-upload
  451. ref="upload1"
  452. :limit="1"
  453. accept="*"
  454. :headers="upload1.headers"
  455. :action="upload1.url"
  456. :disabled="upload1.isUploading"
  457. :on-progress="handleFileUploadProgress"
  458. :on-success="handleFileSuccess1"
  459. :auto-upload="false"
  460. :data="uploadObj"
  461. drag
  462. >
  463. <i class="el-icon-upload"></i>
  464. <div class="el-upload__text">{{ $t('script.uploadTip') }}</div>
  465. </el-upload>
  466. <div slot="footer" class="dialog-footer">
  467. <el-button type="primary" @click="submitFileForm1">{{ $t('normal.confirm') }}</el-button>
  468. <el-button @click="upload1.open = false">{{ $t('normal.cancel') }}</el-button>
  469. </div>
  470. </el-dialog>
  471. </div>
  472. </template>
  473. <script>
  474. import {
  475. listScript,
  476. getScript,
  477. addScript,
  478. downloadTheNodeTemplate, checkDownloadTheNodeTemplate
  479. } from '@/api/bpmprocess/process'
  480. import { getTenantAllList } from '@/api/system/tenant'
  481. import {
  482. updateScript,
  483. delScript,
  484. queryTemplateBaseTable
  485. } from '@/api/bpmprocess/script'
  486. import uuid from '@/utils/bpmn/uuid'
  487. import Editor from 'vue2-ace-editor'
  488. import { v4 as uuidv4 } from 'uuid'
  489. import * as monaco from 'monaco-editor'
  490. import Clipboard from 'clipboard'
  491. import { Cog } from 'lucide-vue'
  492. import { getToken } from '@/utils/auth'
  493. export default {
  494. name: 'Script',
  495. dicts: ['bpm_script_type', 'industry_type', 'zkqy_jbzt','isuploadpage'],
  496. components: { Editor },
  497. data () {
  498. return {
  499. dqRow:null,
  500. openSH:false,
  501. uploadObj:{
  502. id:""
  503. },
  504. // 用户导入参数
  505. upload: {
  506. // 是否显示弹出层(用户导入)
  507. open: false,
  508. // 弹出层标题(用户导入)
  509. title: '',
  510. // 是否禁用上传
  511. isUploading: false,
  512. // 是否更新已经存在的用户数据
  513. updateSupport: 0,
  514. // 设置上传的请求头部
  515. headers: { Authorization: 'Bearer ' + getToken() },
  516. // 上传的地址
  517. url: process.env.VUE_APP_BASE_API + '/system/script/upload'
  518. },
  519. // 用户导入参数
  520. upload1: {
  521. // 是否显示弹出层(用户导入)
  522. open: false,
  523. // 弹出层标题(用户导入)
  524. title: '',
  525. // 是否禁用上传
  526. isUploading: false,
  527. // 是否更新已经存在的用户数据
  528. updateSupport: 0,
  529. // 设置上传的请求头部
  530. headers: { Authorization: 'Bearer ' + getToken() },
  531. // 上传的地址
  532. url: process.env.VUE_APP_BASE_API + '/system/script/uploadPage'
  533. },
  534. openUpdate: true,
  535. // 脚本上传列表
  536. fileList: [], // 上传的文件列表
  537. TenantAllList: [],
  538. // 遮罩层
  539. loading: true,
  540. // 选中数组
  541. ids: [],
  542. // 非单个禁用
  543. single: true,
  544. iddq:"",
  545. // 非多个禁用
  546. multiple: true,
  547. // 显示搜索条件
  548. showSearch: true,
  549. // 总条数
  550. total: 0,
  551. // 流程节点脚本表格数据
  552. scriptList: [],
  553. // 弹出层标题
  554. title: '',
  555. // 是否显示弹出层
  556. open: false,
  557. //表数据
  558. tableNameList: [],
  559. // 查询参数
  560. queryParams: {
  561. pageNum: 1,
  562. pageSize: 10,
  563. scriptKey: null,
  564. tenantId: null,
  565. scriptFunctionName: null,
  566. scriptName: null,
  567. scriptFunctionCode: null,
  568. scriptType: null,
  569. industryType: null,
  570. tableName: null,
  571. scriptDescription: null
  572. },
  573. // 表单参数
  574. form: {
  575. scriptKey: null,
  576. scriptName: null,
  577. scriptType: null,
  578. industryType: null,
  579. tableName: null,
  580. scriptDescription: null,
  581. scriptState:null
  582. },
  583. // 表单校验
  584. rules: {
  585. scriptName: [
  586. { required: true, message: this.$t('script.pleaseEnterScriptName'), trigger: 'blur' }
  587. ],
  588. scriptType: [
  589. { required: true, message: this.$t('script.pleaseSelectScriptType'), trigger: 'change' }
  590. ],
  591. industryType: [
  592. { required: true,message: this.$t('script.pleaseSelectScriptType'), trigger: 'change' }
  593. ],
  594. scriptState: [
  595. { required: true,message: this.$t('script.pleaseSelectExamineState'), trigger: "change" },
  596. ],
  597. },
  598. // 代码编辑器相关数据
  599. monacoEditor: null,
  600. codes: '',
  601. readOnly: false,
  602. drawer: false,
  603. editorOptions: {
  604. selectOnLineNumbers: true,
  605. roundedSelection: false,
  606. readOnly: this.readOnly, // 只读
  607. cursorStyle: 'line', // 光标样式
  608. automaticLayout: false, // 自动布局
  609. glyphMargin: true, // 字形边缘
  610. useTabStops: false,
  611. fontSize: 28, // 字体大小
  612. autoIndent: false // 自动布局
  613. }
  614. }
  615. },
  616. created () {
  617. this.getList()
  618. // this.editorInit();
  619. this.getTenantAllList()
  620. },
  621. methods: {
  622. xzcheck(){
  623. console.log("下载检查脚本")
  624. console.log(this.dqRow);
  625. let scriptKeyObj={"scriptKey":this.dqRow.scriptKey}
  626. checkDownloadTheNodeTemplate(scriptKeyObj)
  627. .then(response => {
  628. // Step 1: 检查响应类型是否为 blob(用于文件下载)
  629. console.log(response)
  630. if (response instanceof Blob) {
  631. const blob = new Blob([response], { type: 'application/zip' })
  632. const url = window.URL.createObjectURL(blob)
  633. // Step 2: 创建临时下载链接
  634. const a = document.createElement('a')
  635. a.href = url
  636. a.download = 'checkScripts.zip' // 下载的文件名
  637. document.body.appendChild(a)
  638. a.click()
  639. // Step 3: 清理临时对象
  640. window.URL.revokeObjectURL(url)
  641. document.body.removeChild(a)
  642. this.$message.success( this.$t('script.messages.downloadSuccessful'))
  643. this.openSH=false;
  644. } else {
  645. console.error(this.$t('script.messages.downloadError'), response.data)
  646. this.$message.error(this.$t('script.messages.downloadError'))
  647. }
  648. })
  649. .catch(error => {
  650. console.error('下载失败:', error)
  651. this.$message.error('下载失败,请稍后再试!')
  652. })
  653. },
  654. //上传组件页面
  655. updateLoadPage(row){
  656. this.upload1.open=true;
  657. this.upload1.title = this.$t('script.titles.uploadComponent')
  658. this.uploadObj.id="";
  659. this.uploadObj.id=row.id
  660. console.log(this.$t('script.comments.uploadComponent'), this.uploadObj)
  661. },
  662. //上传节点模版
  663. uploadTheNodeTemplate () {
  664. this.upload.title = this.$t('script.titles.uploadTenant')
  665. this.upload.open = true
  666. },
  667. // 文件上传中处理
  668. handleFileUploadProgress (event, file, fileList) {
  669. this.upload.isUploading = true
  670. },
  671. // 文件上传成功处理
  672. handleFileSuccess (response, file, fileList) {
  673. this.upload.open = false
  674. this.upload.isUploading = false
  675. this.$refs.upload.clearFiles()
  676. this.$modal.msgSuccess(this.$t('script.messages.uploadSuccess'))
  677. this.getList();
  678. },
  679. // 文件上传成功处理
  680. handleFileSuccess1 (response, file, fileList) {
  681. this.upload1.isUploading = false
  682. this.upload1.open=false;
  683. this.$refs.upload1.clearFiles()
  684. this.$modal.msgSuccess(this.$t('script.messages.uploadSuccess'))
  685. this.getList();
  686. },
  687. // 提交上传文件
  688. submitFileForm () {
  689. this.$refs.upload.submit()
  690. },
  691. submitFileForm1 () {
  692. this.$refs.upload1.submit()
  693. },
  694. // 编辑器初始化
  695. editorInit () {
  696. require('brace/theme/chrome')
  697. require('brace/ext/language_tools') //language extension prerequsite...
  698. require('brace/mode/yaml')
  699. require('brace/mode/json')
  700. require('brace/mode/less')
  701. require('brace/mode/java')
  702. require('brace/snippets/json')
  703. require('brace/mode/lua')
  704. require('brace/snippets/lua')
  705. require('brace/mode/javascript')
  706. require('brace/snippets/javascript')
  707. },
  708. // 复制成功
  709. onCopy () {
  710. this.$modal.msgSuccess(this.$t('script.messages.copySuccess'))
  711. },
  712. //复制失败
  713. onError () {
  714. this.$modal.msgError(this.$t('script.messages.copyError'))
  715. },
  716. /** 查询流程节点脚本列表 */
  717. getList () {
  718. this.loading = true
  719. listScript(this.queryParams).then(response => {
  720. this.scriptList = response.rows
  721. this.total = response.total
  722. this.loading = false
  723. })
  724. },
  725. getTenantAllList () {
  726. getTenantAllList().then(response => {
  727. this.TenantAllList = response.rows
  728. })
  729. },
  730. // 取消按钮
  731. cancel () {
  732. this.open = false
  733. this.reset()
  734. },
  735. // 取消按钮
  736. cancel1 () {
  737. this.openSH = false
  738. this.reset()
  739. },
  740. // 表单重置
  741. reset () {
  742. this.form = {
  743. id: null,
  744. scriptKey: null,
  745. scriptFunctionName: null,
  746. scriptName: null,
  747. scriptFunctionCode: null,
  748. scriptType: null,
  749. industryType: null,
  750. scriptDescription: null,
  751. tableName: null,
  752. delFlag: null,
  753. createBy: null,
  754. createTime: null,
  755. updateBy: null,
  756. updateTime: null
  757. }
  758. this.$nextTick(() => {
  759. console.log(this.$refs['form'])
  760. this.$refs['form'].resetFields()
  761. })
  762. },
  763. /** 搜索按钮操作 */
  764. handleQuery () {
  765. this.queryParams.pageNum = 1
  766. this.getList()
  767. },
  768. /** 重置按钮操作 */
  769. resetQuery () {
  770. this.resetForm('queryForm')
  771. this.handleQuery()
  772. },
  773. // 多选框选中数据
  774. handleSelectionChange (selection) {
  775. this.ids = selection.map(item => item.id)
  776. this.single = selection.length !== 1
  777. this.multiple = !selection.length
  778. },
  779. //下载节点模版
  780. downloadTheNodeTemplate () {
  781. console.log(this.ids, '选择的节点id')
  782. let s = this.ids.join('T')
  783. let idArray = {
  784. id: s
  785. }
  786. downloadTheNodeTemplate(idArray)
  787. .then(response => {
  788. // Step 1: 检查响应类型是否为 blob(用于文件下载)
  789. console.log(response)
  790. if (response instanceof Blob) {
  791. const blob = new Blob([response], { type: 'application/zip' })
  792. const url = window.URL.createObjectURL(blob)
  793. // Step 2: 创建临时下载链接
  794. const a = document.createElement('a')
  795. a.href = url
  796. a.download = 'scripts.zip' // 下载的文件名
  797. document.body.appendChild(a)
  798. a.click()
  799. // Step 3: 清理临时对象
  800. window.URL.revokeObjectURL(url)
  801. document.body.removeChild(a)
  802. this.$message.success(this.$t('script.messages.downloadSuccessful'))
  803. } else {
  804. console.error(this.$t('script.messages.responseDataNotValidFileFormat'), response.data)
  805. this.$message.error(this.$t('script.messages.downloadError'))
  806. }
  807. })
  808. .catch(error => {
  809. console.error('下载失败:', error)
  810. this.$message.error(this.$t('script.messages.downloadRetry'))
  811. })
  812. },
  813. /** 新增按钮操作 */
  814. handleAdd () {
  815. this.monacoEditor?.dispose()
  816. this.reset()
  817. this.$nextTick(() => {
  818. const newScriptKey = uuidv4()
  819. this.$set(this.form, 'scriptKey', 'script_'+newScriptKey)
  820. console.log('Generated scriptKey:', this.form.scriptKey)
  821. this.open = true
  822. this.title = this.$t('script.titles.addScript')
  823. });
  824. },
  825. /** 修改按钮操作 */
  826. handleUpdate (row) {
  827. this.monacoEditor?.dispose()
  828. // this.open = true
  829. this.reset()
  830. queryTemplateBaseTable().then(response => {
  831. this.tableNameList = response.data
  832. })
  833. const id = row.id || this.ids
  834. getScript(id).then(response => {
  835. response.data.scriptType = response.data.scriptType.toString()
  836. response.data.tableName = response.data.tableName
  837. ? response.data.tableName.split(',')
  838. : []
  839. console.log(response.data.tableName)
  840. this.form = response.data
  841. this.open = true
  842. this.title = this.$t('script.titles.updateScript')
  843. })
  844. },
  845. examine(row){
  846. console.log(this.$t('script.comments.examine'), row.scriptState);
  847. this.dqRow=row;
  848. // this.form.id=row.id;
  849. this.$set(this.form,'scriptState',"1")
  850. this.$set(this.form,'id',row.id)
  851. this.openSH=true;
  852. this.title = this.$t('script.titles.examineScript')
  853. this.$nextTick(() => {
  854. console.log(this.$refs['form1'])
  855. this.$refs['form1'].resetFields()
  856. });
  857. },
  858. /** 提交按钮 */
  859. submitForm () {
  860. // console.log(this.monacoEditor?.getValue());
  861. this.$refs['form'].validate(valid => {
  862. if (valid) {
  863. this.form.tableName = this.form.tableName?.join(',')
  864. if (this.form.id != null) {
  865. updateScript(this.form).then(response => {
  866. this.$modal.msgSuccess(this.$t('script.messages.updateSuccess'))
  867. this.open = false
  868. this.openSH=false;
  869. this.getList()
  870. })
  871. } else {
  872. addScript(this.form).then(response => {
  873. console.log(this.form)
  874. this.$modal.msgSuccess(this.$t('script.messages.addSuccess'))
  875. this.open = false
  876. this.getList()
  877. })
  878. }
  879. }
  880. })
  881. },
  882. /** 提交按钮 */
  883. submitForm2 () {
  884. // console.log(this.monacoEditor?.getValue());
  885. this.$refs['form1'].validate(valid => {
  886. if (valid) {
  887. // this.form.tableName = this.form.tableName?.join(',')
  888. if (this.form.id != null) {
  889. updateScript(this.form).then(response => {
  890. this.$modal.msgSuccess(this.$t('script.messages.updateSuccess'))
  891. this.open = false
  892. this.openSH=false;
  893. this.getList()
  894. })
  895. } else {
  896. addScript(this.form).then(response => {
  897. console.log(this.form)
  898. this.$modal.msgSuccess(this.$t('script.messages.addSuccess'))
  899. this.open = false
  900. this.getList()
  901. })
  902. }
  903. }
  904. })
  905. },
  906. /** 删除按钮操作 */
  907. handleDelete (row) {
  908. const ids = row.id || this.ids
  909. this.$modal
  910. .confirm(this.$t('script.messages.deleteConfirm') + ids + this.$t('script.messages.dataItem'))
  911. .then(function () {
  912. return delScript(ids)
  913. })
  914. .then(() => {
  915. this.getList()
  916. this.$modal.msgSuccess(this.$t('script.messages.deleteSuccess'))
  917. })
  918. .catch(() => {})
  919. },
  920. /** 导出按钮操作 */
  921. handleExport () {
  922. this.download(
  923. 'system/script/export',
  924. {
  925. ...this.queryParams
  926. },
  927. `script_${new Date().getTime()}.xlsx`
  928. )
  929. },
  930. // 获取字典对应label
  931. getDictLabel (value, dictLsit = []) {
  932. return dictLsit.find(item => {
  933. return item.value == value
  934. })?.label
  935. },
  936. // 抽屉打开回调
  937. drawerOpenHandler () {
  938. this.monacoEditor?.dispose()
  939. this.drawer = true
  940. this.$nextTick(() => {
  941. this.monacoEditor = monaco.editor.create(this.$refs.container, {
  942. value: this.form.scriptFunctionCode,
  943. language: 'java',
  944. theme: 'vs-dark', // 编辑器主题:vs, hc-black, or vs-dark,更多选择详见官网
  945. contextmenu: false, // 禁用右键菜单
  946. editorOptions: this.editorOptions // 同codes
  947. })
  948. })
  949. },
  950. // 抽屉关闭前回调
  951. drawerHandleClose (done) {
  952. this.$confirm(this.$t('script.messages.closeEditorConfirm'))
  953. .then(
  954. val => {
  955. this.form.scriptFunctionCode = this.monacoEditor?.getValue()
  956. done()
  957. },
  958. res => {
  959. done()
  960. }
  961. )
  962. .catch(() => {})
  963. }
  964. }
  965. }
  966. </script>
  967. <style lang="scss" scoped>
  968. .codeEditBox {
  969. width: 100%;
  970. height: 200px;
  971. }
  972. // ::v-deep div {
  973. // font-family: "新宋体", serif;
  974. // // font-family: Fira code, Fira Mono, Consolas, Menlo, Courier, monospace;
  975. // font-size: 16px;
  976. // }
  977. .monaco-container {
  978. width: 100%;
  979. height: 100%;
  980. }
  981. </style>