index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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>
  14. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  15. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  16. </el-form-item>
  17. </el-form>
  18. <el-row :gutter="10" class="mb8">
  19. <el-col :span="1.5">
  20. <el-button
  21. type="primary"
  22. icon="el-icon-plus"
  23. size="mini"
  24. @click="handleAdd"
  25. v-hasPermi="['company:wxDialog:add']"
  26. >新增</el-button>
  27. </el-col>
  28. <el-col :span="1.5">
  29. <el-button
  30. type="success"
  31. icon="el-icon-edit"
  32. size="mini"
  33. :disabled="single"
  34. @click="handleUpdate"
  35. v-hasPermi="['company:wxDialog:edit']"
  36. >修改</el-button>
  37. </el-col>
  38. <el-col :span="1.5">
  39. <el-button
  40. type="danger"
  41. icon="el-icon-delete"
  42. size="mini"
  43. :disabled="multiple"
  44. @click="handleDelete"
  45. v-hasPermi="['company:wxDialog:remove']"
  46. >删除</el-button>
  47. </el-col>
  48. <el-col :span="1.5">
  49. <el-button
  50. type="warning"
  51. icon="el-icon-download"
  52. size="mini"
  53. @click="handleExport"
  54. v-hasPermi="['company:wxDialog:export']"
  55. >导出</el-button>
  56. </el-col>
  57. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  58. </el-row>
  59. <el-table v-loading="loading" :data="wxDialogList" @selection-change="handleSelectionChange">
  60. <el-table-column type="selection" width="55" align="center" />
  61. <el-table-column label="id" align="center" prop="id" />
  62. <el-table-column label="名称" align="center" prop="name" />
  63. <el-table-column label="模板" align="center" prop="templateDetails" />
  64. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  65. <template slot-scope="scope">
  66. <el-button
  67. size="mini"
  68. type="text"
  69. icon="el-icon-edit"
  70. @click="handleUpdate(scope.row)"
  71. v-hasPermi="['company:wxDialog:edit']"
  72. >修改</el-button>
  73. <el-button
  74. size="mini"
  75. type="text"
  76. icon="el-icon-delete"
  77. @click="handleDelete(scope.row)"
  78. v-hasPermi="['company:wxDialog:remove']"
  79. >删除</el-button>
  80. </template>
  81. </el-table-column>
  82. </el-table>
  83. <pagination
  84. v-show="total>0"
  85. :total="total"
  86. :page.sync="queryParams.pageNum"
  87. :limit.sync="queryParams.pageSize"
  88. @pagination="getList"
  89. />
  90. <!-- 添加或修改添加微信话术对话框 -->
  91. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  92. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  93. <el-form-item label="名称" prop="name">
  94. <el-input v-model="form.name" placeholder="请输入名称" />
  95. </el-form-item>
  96. <el-form-item label="模板" prop="templateDetails">
  97. <el-input v-model="form.templateDetails" type="textarea" placeholder="请输入内容" />
  98. </el-form-item>
  99. </el-form>
  100. <div slot="footer" class="dialog-footer">
  101. <el-button type="primary" @click="submitForm">确 定</el-button>
  102. <el-button @click="cancel">取 消</el-button>
  103. </div>
  104. </el-dialog>
  105. </div>
  106. </template>
  107. <script>
  108. import { listWxDialog, getWxDialog, delWxDialog, addWxDialog, updateWxDialog, exportWxDialog } from "@/api/company/wxDialog";
  109. export default {
  110. name: "WxDialog",
  111. data() {
  112. return {
  113. // 遮罩层
  114. loading: true,
  115. // 选中数组
  116. ids: [],
  117. // 非单个禁用
  118. single: true,
  119. // 非多个禁用
  120. multiple: true,
  121. // 显示搜索条件
  122. showSearch: true,
  123. // 总条数
  124. total: 0,
  125. // 添加微信话术表格数据
  126. wxDialogList: [],
  127. // 弹出层标题
  128. title: "",
  129. // 是否显示弹出层
  130. open: false,
  131. // 查询参数
  132. queryParams: {
  133. pageNum: 1,
  134. pageSize: 10,
  135. name: null,
  136. templateDetails: null,
  137. createUser: null
  138. },
  139. // 表单参数
  140. form: {},
  141. // 表单校验
  142. rules: {
  143. }
  144. };
  145. },
  146. created() {
  147. this.getList();
  148. },
  149. methods: {
  150. /** 查询添加微信话术列表 */
  151. getList() {
  152. this.loading = true;
  153. listWxDialog(this.queryParams).then(response => {
  154. this.wxDialogList = response.rows;
  155. this.total = response.total;
  156. this.loading = false;
  157. });
  158. },
  159. // 取消按钮
  160. cancel() {
  161. this.open = false;
  162. this.reset();
  163. },
  164. // 表单重置
  165. reset() {
  166. this.form = {
  167. id: null,
  168. name: null,
  169. templateDetails: null,
  170. createTime: null,
  171. createUser: null
  172. };
  173. this.resetForm("form");
  174. },
  175. /** 搜索按钮操作 */
  176. handleQuery() {
  177. this.queryParams.pageNum = 1;
  178. this.getList();
  179. },
  180. /** 重置按钮操作 */
  181. resetQuery() {
  182. this.resetForm("queryForm");
  183. this.handleQuery();
  184. },
  185. // 多选框选中数据
  186. handleSelectionChange(selection) {
  187. this.ids = selection.map(item => item.id)
  188. this.single = selection.length!==1
  189. this.multiple = !selection.length
  190. },
  191. /** 新增按钮操作 */
  192. handleAdd() {
  193. this.reset();
  194. this.open = true;
  195. this.title = "添加添加微信话术";
  196. },
  197. /** 修改按钮操作 */
  198. handleUpdate(row) {
  199. this.reset();
  200. const id = row.id || this.ids
  201. getWxDialog(id).then(response => {
  202. this.form = response.data;
  203. this.open = true;
  204. this.title = "修改添加微信话术";
  205. });
  206. },
  207. /** 提交按钮 */
  208. submitForm() {
  209. this.$refs["form"].validate(valid => {
  210. if (valid) {
  211. if (this.form.id != null) {
  212. updateWxDialog(this.form).then(response => {
  213. if (response.code === 200) {
  214. this.msgSuccess("修改成功");
  215. this.open = false;
  216. this.getList();
  217. }
  218. });
  219. } else {
  220. addWxDialog(this.form).then(response => {
  221. if (response.code === 200) {
  222. this.msgSuccess("新增成功");
  223. this.open = false;
  224. this.getList();
  225. }
  226. });
  227. }
  228. }
  229. });
  230. },
  231. /** 删除按钮操作 */
  232. handleDelete(row) {
  233. const ids = row.id || this.ids;
  234. this.$confirm('是否确认删除添加微信话术编号为"' + ids + '"的数据项?', "警告", {
  235. confirmButtonText: "确定",
  236. cancelButtonText: "取消",
  237. type: "warning"
  238. }).then(function() {
  239. return delWxDialog(ids);
  240. }).then(() => {
  241. this.getList();
  242. this.msgSuccess("删除成功");
  243. }).catch(function() {});
  244. },
  245. /** 导出按钮操作 */
  246. handleExport() {
  247. const queryParams = this.queryParams;
  248. this.$confirm('是否确认导出所有添加微信话术数据项?', "警告", {
  249. confirmButtonText: "确定",
  250. cancelButtonText: "取消",
  251. type: "warning"
  252. }).then(function() {
  253. return exportWxDialog(queryParams);
  254. }).then(response => {
  255. this.download(response.msg);
  256. }).catch(function() {});
  257. }
  258. }
  259. };
  260. </script>