index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="模板标题" prop="name">
  5. <el-input
  6. v-model="queryParams.name"
  7. placeholder="请输入模板标题"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="状态" prop="status">
  14. <el-select v-model="queryParams.status" placeholder="请选择状态" clearable size="small">
  15. <el-option
  16. v-for="dict in statusOptions"
  17. :key="dict.dictValue"
  18. :label="dict.dictLabel"
  19. :value="dict.dictValue"
  20. />
  21. </el-select>
  22. </el-form-item>
  23. <el-form-item label="模板类型" prop="sendType">
  24. <el-select v-model="queryParams.sendType" placeholder="请选择类型" clearable size="small">
  25. <el-option
  26. v-for="dict in sysQwSopType"
  27. :key="dict.dictValue"
  28. :label="dict.dictLabel"
  29. :value="dict.dictValue"
  30. />
  31. </el-select>
  32. </el-form-item>
  33. <el-form-item label="排序" prop="sort">
  34. <el-input
  35. v-model="queryParams.sort"
  36. placeholder="请输入排序"
  37. clearable
  38. size="small"
  39. @keyup.enter.native="handleQuery"
  40. />
  41. </el-form-item>
  42. <el-form-item>
  43. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  44. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  45. </el-form-item>
  46. </el-form>
  47. <el-row :gutter="10" class="mb8">
  48. <el-col :span="1.5">
  49. <el-dropdown
  50. @command="handleCommand"
  51. trigger="click"
  52. placement="bottom-start"
  53. >
  54. <el-dropdown-menu slot="dropdown" style="width: 140px;">
  55. <el-dropdown-item
  56. v-for="option in sysQwSopType"
  57. :key="option.dictValue"
  58. :command="option.dictValue"
  59. >
  60. <i :class="option.iconClass" style="margin-right: 10px;"></i>
  61. {{ option.dictLabel }}
  62. </el-dropdown-item>
  63. </el-dropdown-menu>
  64. <span class="el-dropdown-link" >
  65. <el-button
  66. type="primary"
  67. icon="el-icon-plus"
  68. plain
  69. size="mini"
  70. v-hasPermi="['app:template:add']"
  71. >
  72. 新增模板
  73. </el-button>
  74. </span>
  75. </el-dropdown>
  76. </el-col>
  77. <el-col :span="1.5">
  78. <el-button
  79. type="danger"
  80. plain
  81. icon="el-icon-delete"
  82. size="mini"
  83. :disabled="multiple"
  84. @click="handleDelete"
  85. v-hasPermi="['app:template:delete']"
  86. >删除</el-button>
  87. </el-col>
  88. <el-col :span="1.5">
  89. <el-button
  90. type="warning"
  91. plain
  92. icon="el-icon-download"
  93. size="mini"
  94. :loading="exportLoading"
  95. @click="handleExport"
  96. v-hasPermi="['app:template:export']"
  97. >导出</el-button>
  98. </el-col>
  99. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  100. </el-row>
  101. <el-table v-loading="loading" border :data="sopTempList" @selection-change="handleSelectionChange">
  102. <el-table-column type="selection" width="55" align="center" />
  103. <el-table-column label="模板编号" align="center" prop="id" />
  104. <el-table-column label="模板标题" align="center" prop="name" />
  105. <el-table-column label="模板类型" align="center" prop="sendType" >
  106. <template slot-scope="scope">
  107. <dict-tag :options="sysQwSopType" :value="scope.row.sendType"/>
  108. </template>
  109. </el-table-column>
  110. <el-table-column label="间隔天数" align="center" prop="gap" />
  111. <el-table-column label="状态" align="center" prop="status">
  112. <template slot-scope="scope">
  113. <dict-tag :options="statusOptions" :value="scope.row.status"/>
  114. </template>
  115. </el-table-column>
  116. <el-table-column label="创建时间" align="center" prop="createTime" />
  117. <el-table-column label="修改时间" align="center" prop="updateTime" />
  118. <el-table-column label="排序" align="center" prop="sort" />
  119. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  120. <template slot-scope="scope">
  121. <el-button
  122. size="mini"
  123. type="text"
  124. icon="el-icon-connection"
  125. @click="copyTemplate(scope.row)"
  126. v-hasPermi="['app:template:copy']"
  127. >复制模板</el-button>
  128. <el-button
  129. size="mini"
  130. type="text"
  131. icon="el-icon-share"
  132. @click="shareTemplate(scope.row)"
  133. v-hasPermi="['app:template:share']"
  134. >分享模板</el-button>
  135. <el-button
  136. size="mini"
  137. type="text"
  138. icon="el-icon-s-promotion"
  139. @click="handleQueryDetails(scope.row)"
  140. >详情</el-button>
  141. <el-button
  142. size="mini"
  143. type="text"
  144. icon="el-icon-edit"
  145. @click="handleUpdate(scope.row)"
  146. v-hasPermi="['app:template:edit']"
  147. >修改</el-button>
  148. <el-button
  149. size="mini"
  150. type="text"
  151. icon="el-icon-edit"
  152. @click="handleUpdate2(scope.row)"
  153. v-hasPermi="['app:template:rule']"
  154. >管理规则</el-button>
  155. <el-button
  156. size="mini"
  157. type="text"
  158. icon="el-icon-edit"
  159. @click="updateImageFun(scope.row.id)"
  160. v-hasPermi="['app:template:updateImage']"
  161. >更新图片</el-button>
  162. <el-button
  163. :disabled="scope.row.status == 0"
  164. size="mini"
  165. type="text"
  166. icon="el-icon-delete"
  167. @click="handleDelete(scope.row)"
  168. v-hasPermi="['app:template:stop']"
  169. >停用</el-button>
  170. </template>
  171. </el-table-column>
  172. </el-table>
  173. <pagination
  174. v-show="total>0"
  175. :total="total"
  176. :page.sync="queryParams.pageNum"
  177. :limit.sync="queryParams.pageSize"
  178. @pagination="getList"
  179. />
  180. <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
  181. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  182. <el-form-item label="名称" prop="name">
  183. <el-input v-model="form.name" placeholder="请输入模板标题" />
  184. </el-form-item>
  185. <el-form-item label="状态">
  186. <el-radio-group v-model="form.status">
  187. <el-radio
  188. v-for="dict in statusOptions"
  189. :key="dict.dictValue"
  190. :label="dict.dictValue"
  191. >{{dict.dictLabel}}</el-radio>
  192. </el-radio-group>
  193. </el-form-item>
  194. <el-form-item label="间隔天数" prop="gap" v-show="false">
  195. <el-input-number v-model="form.gap" :min="1" label="间隔天数"></el-input-number>
  196. <div style="color: #999;font-size: 14px;display: flex;align-items: center;">
  197. <i class="el-icon-info"></i>
  198. 设置间隔几天发送sop任务模板内容。比如 设置间隔2天。则第一天,第三天,第五天时 才发送科普模板中的第一天,第二天,第三天的内容。(默认建议1天,好精准匹配不迷糊)
  199. </div>
  200. </el-form-item>
  201. <el-form-item label="排序" prop="sort" v-show="false">
  202. <el-input-number v-model="form.sort" :min="0" label="排序"></el-input-number>
  203. </el-form-item>
  204. </el-form>
  205. <div slot="footer" class="dialog-footer" style="float: right;">
  206. <el-button type="primary" @click="submitForm">确 定</el-button>
  207. <el-button @click="cancel">取 消</el-button>
  208. </div>
  209. </el-dialog>
  210. </div>
  211. </template>
  212. <script>
  213. import {
  214. listSopTemp,
  215. getSopTemp,
  216. delSopTemp,
  217. updateTemp,
  218. copyTemplate,
  219. addTemp,
  220. updateImage,
  221. exportSopTemp,
  222. shareSopTemp
  223. } from "@/api/app/sop/template";
  224. export default {
  225. name: "sopTemplate",
  226. data() {
  227. return {
  228. // 遮罩层
  229. loading: true,
  230. companysloading: false,
  231. // 导出遮罩层
  232. exportLoading: false,
  233. // 选中数组
  234. ids: [],
  235. //选中的公司
  236. companys:[],
  237. deptOptions: [],
  238. // 非单个禁用
  239. single: true,
  240. // 非多个禁用
  241. multiple: true,
  242. // 显示搜索条件
  243. showSearch: true,
  244. // 总条数
  245. companyTotal: 0,
  246. total:0,
  247. sendType:0,
  248. // sop模板表格数据
  249. sopTempList: [],
  250. sysQwSopType:[],
  251. companyList:[],
  252. // 弹出层标题
  253. title: "",
  254. // 是否显示弹出层
  255. open: false,
  256. command: 0,
  257. // 状态字典
  258. statusOptions: [],
  259. shareOptions:{
  260. title:'分享模板',
  261. open:false,
  262. templateId:null,
  263. },
  264. queryCompanyParams: {
  265. pageNum: 1,
  266. pageSize: 10,
  267. companyName: null,
  268. status: null,
  269. },
  270. // 查询参数
  271. queryParams: {
  272. pageNum: 1,
  273. pageSize: 10,
  274. name: null,
  275. setting: null,
  276. status: '1',
  277. sort: null,
  278. companyId: null
  279. },
  280. // 表单参数
  281. form: {},
  282. // 表单校验
  283. rules: {
  284. name: [
  285. { required: true, message: '名称不能为空', trigger: 'blur' }
  286. ],
  287. status: [
  288. { required: true, message: '状态不能为空', trigger: 'blur' }
  289. ],
  290. sort: [
  291. { required: true, message: '排序不能为空', trigger: 'blur' }
  292. ],
  293. gap: [
  294. { required: true, message: '间隔天数不能为空', trigger: 'blur' }
  295. ],
  296. // createByDept:[
  297. // { required: true, message: '归属部门不能为空', trigger: 'blur' }
  298. // ]
  299. },
  300. contentRules:{
  301. time:[{ required: true, message: '时间不能为空', trigger: 'blur' }],
  302. }
  303. };
  304. },
  305. created() {
  306. this.getList();
  307. // this.getDeptTreeSelect();
  308. this.getDicts("app_normal_disabled_status").then(response => {
  309. this.statusOptions = response.data;
  310. });
  311. // this.getCompanyList();
  312. this.getDicts("app_sop_type").then(response => {
  313. this.sysQwSopType = response.data;
  314. });
  315. },
  316. methods: {
  317. updateImage,
  318. handleCompanyQuery(){
  319. this.queryCompanyParams.pageNum = 1;
  320. this.getCompanyList();
  321. },
  322. resetCompanyQuery(){
  323. this.resetForm("queryCompanyForm");
  324. this.handleCompanyQuery();
  325. },
  326. getDeptTreeSelect() {
  327. treeselect().then((response) => {
  328. this.deptOptions = response.data;
  329. });
  330. },
  331. /** 查询企业列表 */
  332. getCompanyList() {
  333. this.companysloading = true;
  334. listCompany(this.queryCompanyParams).then(response => {
  335. this.companyList = response.rows;
  336. this.companyTotal = response.total;
  337. this.companysloading = false;
  338. });
  339. },
  340. /** 查询sop模板列表 */
  341. getList() {
  342. this.loading = true;
  343. listSopTemp(this.queryParams).then(response => {
  344. this.sopTempList = response.rows;
  345. this.total = response.total;
  346. this.loading = false;
  347. });
  348. },
  349. // 取消按钮
  350. cancel() {
  351. this.open = false;
  352. this.reset();
  353. },
  354. // 表单重置
  355. reset() {
  356. this.form = {
  357. gap: 1,
  358. sendType: this.sendType,
  359. sort: 0,
  360. status: "1",
  361. createByDept:null,
  362. };
  363. this.resetForm("form");
  364. },
  365. /** 搜索按钮操作 */
  366. handleQuery() {
  367. this.queryParams.pageNum = 1;
  368. this.getList();
  369. },
  370. /** 重置按钮操作 */
  371. resetQuery() {
  372. this.resetForm("queryForm");
  373. this.handleQuery();
  374. },
  375. updateImageFun(id){
  376. let loadingRock = this.$loading({
  377. lock: true,
  378. text: '正在执行中请稍后~~请不要刷新页面!!',
  379. spinner: 'el-icon-loading',
  380. background: 'rgba(0, 0, 0, 0.7)'
  381. });
  382. updateImage(id).then(response => {
  383. this.getList();
  384. this.$message.success("更新图片 完成!");
  385. }).finally(res=>{
  386. loadingRock.close();
  387. })
  388. },
  389. handleCommand(command){
  390. // if (command==4) {
  391. // this.$router.push('/qw/sopTemp/addAiChatTemp')
  392. // }else{
  393. this.sendType = command;
  394. this.title = "新增";
  395. this.reset();
  396. this.open = true;
  397. // this.$router.push('/qw/sopTemp/addTemp/'+command)
  398. // }
  399. },
  400. // 多选框选中数据
  401. handleSelectionChange(selection) {
  402. this.ids = selection.map(item => item.id)
  403. this.single = selection.length!==1
  404. this.multiple = !selection.length
  405. },
  406. //客服公司多选
  407. handleSelectionCompany(selection){
  408. this.companys=selection.map(item => item.companyId)
  409. this.single = selection.length!==1
  410. this.multiple = !selection.length
  411. },
  412. /** 新增按钮操作 */
  413. // handleAdd() {
  414. // this.$router.push('/qw/sopTemp/addSopTemp')
  415. // },
  416. /**
  417. * 查看详情
  418. */
  419. handleQueryDetails(row){
  420. // if (row.sendType==4) {
  421. // this.$router.push(`/qw/sopTemp/updateAiChatTemp/${row.id}/3`)
  422. // }else{
  423. this.$router.push(`/user/sopTemp/updateSopTemp/${row.id}/3`)
  424. // }
  425. },
  426. /** 修改按钮操作 */
  427. handleUpdate(row) {
  428. // if (row.sendType==4) {
  429. // this.$router.push(`/qw/sopTemp/updateAiChatTemp/${row.id}/1`)
  430. // }else{
  431. this.getInfo(row.id, 1);
  432. // this.$router.push(`/qw/sopTemp/updateTemp/${row.id}/1`)
  433. // }
  434. },
  435. /** 修改按钮操作 */
  436. handleUpdate2(row) {
  437. // if (row.sendType==4) {
  438. // this.$router.push(`/qw/sopTemp/updateAiChatTemp/${row.id}/1`)
  439. // }else{
  440. this.$router.push(`/user/sopTemp/updateSopTemp/${row.id}/1`)
  441. // }
  442. },
  443. /** 分享模板 */
  444. shareTemplate(row) {
  445. return this.msgError('该功能暂未开通!');
  446. // this.shareOptions.open=true;
  447. // this.shareOptions.templateId=row.id;
  448. },
  449. /**
  450. * 复制模板
  451. */
  452. copyTemplate(row){
  453. // if(row.sendType==4){
  454. // this.$router.push(`/qw/sopTemp/updateAiChatTemp/${row.id}/2`)
  455. // }else{
  456. this.getInfo(row.id, 2);
  457. // this.$router.push(`/qw/sopTemp/updateSopTemp/${row.id}/2`)
  458. // }
  459. },
  460. getInfo(id, command){
  461. getSopTemp(id).then(response => {
  462. this.command = command;
  463. if(command == 2){
  464. this.title = "复制";
  465. }
  466. if(command == 1){
  467. this.title = "修改";
  468. }
  469. this.form = response.data;
  470. this.open = true;
  471. });
  472. },
  473. /** 提交按钮 */
  474. submitForm() {
  475. delete this.form.rules
  476. this.$refs["form"].validate(valid => {
  477. if (valid) {
  478. if(this.command == 2){
  479. copyTemplate(this.form).then(response => {
  480. this.msgSuccess("复制成功");
  481. this.open = false;
  482. this.getList();
  483. });
  484. }else{
  485. if (this.form.id != null) {
  486. updateTemp(this.form).then(response => {
  487. this.msgSuccess("修改成功");
  488. this.open = false;
  489. this.getList();
  490. });
  491. } else {
  492. addTemp(this.form).then(response => {
  493. this.msgSuccess("新增成功");
  494. this.open = false;
  495. this.getList();
  496. });
  497. }
  498. }
  499. }
  500. });
  501. },
  502. handleShareTemplate() {
  503. const companyIds = this.companys;
  504. let templateId = this.shareOptions.templateId;
  505. this.$confirm("确定将模板分享给 公司编号为:" + companyIds + "的公司?", "提醒", {
  506. confirmButtonText: "确定",
  507. cancelButtonText: "取消",
  508. type: "warning"
  509. }).then(function () {
  510. return shareSopTemp({companyIds: companyIds, templeId: templateId});
  511. }).then(() => {
  512. this.companys=[];
  513. this.shareOptions.open=false;
  514. this.getList();
  515. this.msgSuccess("分享成功");
  516. });
  517. },
  518. /** 删除按钮操作 */
  519. handleDelete(row) {
  520. const ids = row.id || this.ids;
  521. this.$confirm('是否确认删除sop模板编号为"' + ids + '"的数据项?', "警告", {
  522. confirmButtonText: "确定",
  523. cancelButtonText: "取消",
  524. type: "warning"
  525. }).then(function() {
  526. return delSopTemp(ids);
  527. }).then(() => {
  528. this.getList();
  529. this.msgSuccess("删除成功");
  530. }).catch(() => {});
  531. },
  532. /** 导出按钮操作 */
  533. handleExport() {
  534. const queryParams = this.queryParams;
  535. this.$confirm('是否确认导出所有sop模板数据项?', "警告", {
  536. confirmButtonText: "确定",
  537. cancelButtonText: "取消",
  538. type: "warning"
  539. }).then(() => {
  540. this.exportLoading = true;
  541. return exportSopTemp(queryParams);
  542. }).then(response => {
  543. this.download(response.msg);
  544. this.exportLoading = false;
  545. }).catch(() => {});
  546. }
  547. }
  548. };
  549. </script>
  550. <style lang="scss" scoped>
  551. ::v-deep .el-dialog__footer {
  552. height: 55px;
  553. }
  554. </style>