index.vue 19 KB

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