index.vue 19 KB

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