index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  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="销售ID" prop="companyUserId">
  5. <el-input
  6. v-model="queryParams.companyUserId"
  7. placeholder="请输入销售ID"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="消息类型 1客户消息 " prop="msgType">
  14. <el-select v-model="queryParams.msgType" placeholder="请选择消息类型 1客户消息 " clearable size="small">
  15. <el-option label="请选择字典生成" value="" />
  16. </el-select>
  17. </el-form-item>
  18. <el-form-item label="标题" prop="title">
  19. <el-input
  20. v-model="queryParams.title"
  21. placeholder="请输入标题"
  22. clearable
  23. size="small"
  24. @keyup.enter.native="handleQuery"
  25. />
  26. </el-form-item>
  27. <el-form-item label="对象ID 多个用,分隔" prop="objId">
  28. <el-input
  29. v-model="queryParams.objId"
  30. placeholder="请输入对象ID 多个用,分隔"
  31. clearable
  32. size="small"
  33. @keyup.enter.native="handleQuery"
  34. />
  35. </el-form-item>
  36. <el-form-item label="对象ID 多个用,分隔" prop="isRead">
  37. <el-input
  38. v-model="queryParams.isRead"
  39. placeholder="请输入对象ID 多个用,分隔"
  40. clearable
  41. size="small"
  42. @keyup.enter.native="handleQuery"
  43. />
  44. </el-form-item>
  45. <el-form-item label="对象ID 多个用,分隔" prop="companyId">
  46. <el-input
  47. v-model="queryParams.companyId"
  48. placeholder="请输入对象ID 多个用,分隔"
  49. clearable
  50. size="small"
  51. @keyup.enter.native="handleQuery"
  52. />
  53. </el-form-item>
  54. <el-form-item>
  55. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  56. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  57. </el-form-item>
  58. </el-form>
  59. <el-row :gutter="10" class="mb8">
  60. <el-col :span="1.5">
  61. <el-button
  62. type="primary"
  63. icon="el-icon-plus"
  64. size="mini"
  65. @click="handleAdd"
  66. v-hasPermi="['crm:msg:add']"
  67. >新增</el-button>
  68. </el-col>
  69. <el-col :span="1.5">
  70. <el-button
  71. type="success"
  72. icon="el-icon-edit"
  73. size="mini"
  74. :disabled="single"
  75. @click="handleUpdate"
  76. v-hasPermi="['crm:msg:edit']"
  77. >修改</el-button>
  78. </el-col>
  79. <el-col :span="1.5">
  80. <el-button
  81. type="danger"
  82. icon="el-icon-delete"
  83. size="mini"
  84. :disabled="multiple"
  85. @click="handleDelete"
  86. v-hasPermi="['crm:msg:remove']"
  87. >删除</el-button>
  88. </el-col>
  89. <el-col :span="1.5">
  90. <el-button
  91. type="warning"
  92. icon="el-icon-download"
  93. size="mini"
  94. @click="handleExport"
  95. v-hasPermi="['crm:msg:export']"
  96. >导出</el-button>
  97. </el-col>
  98. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  99. </el-row>
  100. <el-table v-loading="loading" :data="msgList" @selection-change="handleSelectionChange">
  101. <el-table-column type="selection" width="55" align="center" />
  102. <el-table-column label="ID" align="center" prop="msgId" />
  103. <el-table-column label="销售ID" align="center" prop="companyUserId" />
  104. <el-table-column label="消息类型 1客户消息 " align="center" prop="msgType" />
  105. <el-table-column label="标题" align="center" prop="title" />
  106. <el-table-column label="内容" align="center" prop="content" />
  107. <el-table-column label="对象ID 多个用,分隔" align="center" prop="objId" />
  108. <el-table-column label="对象ID 多个用,分隔" align="center" prop="isRead" />
  109. <el-table-column label="对象ID 多个用,分隔" align="center" prop="companyId" />
  110. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  111. <template slot-scope="scope">
  112. <el-button
  113. size="mini"
  114. type="text"
  115. icon="el-icon-edit"
  116. @click="handleUpdate(scope.row)"
  117. v-hasPermi="['crm:msg:edit']"
  118. >修改</el-button>
  119. <el-button
  120. size="mini"
  121. type="text"
  122. icon="el-icon-delete"
  123. @click="handleDelete(scope.row)"
  124. v-hasPermi="['crm:msg:remove']"
  125. >删除</el-button>
  126. </template>
  127. </el-table-column>
  128. </el-table>
  129. <pagination
  130. v-show="total>0"
  131. :total="total"
  132. :page.sync="queryParams.pageNum"
  133. :limit.sync="queryParams.pageSize"
  134. @pagination="getList"
  135. />
  136. <!-- 添加或修改 消息对话框 -->
  137. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  138. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  139. <el-form-item label="销售ID" prop="companyUserId">
  140. <el-input v-model="form.companyUserId" placeholder="请输入销售ID" />
  141. </el-form-item>
  142. <el-form-item label="消息类型 1客户消息 " prop="msgType">
  143. <el-select v-model="form.msgType" placeholder="请选择消息类型 1客户消息 ">
  144. <el-option label="请选择字典生成" value="" />
  145. </el-select>
  146. </el-form-item>
  147. <el-form-item label="标题" prop="title">
  148. <el-input v-model="form.title" placeholder="请输入标题" />
  149. </el-form-item>
  150. <el-form-item label="内容">
  151. <editor v-model="form.content" :min-height="192"/>
  152. </el-form-item>
  153. <el-form-item label="对象ID 多个用,分隔" prop="objId">
  154. <el-input v-model="form.objId" placeholder="请输入对象ID 多个用,分隔" />
  155. </el-form-item>
  156. <el-form-item label="对象ID 多个用,分隔" prop="isRead">
  157. <el-input v-model="form.isRead" placeholder="请输入对象ID 多个用,分隔" />
  158. </el-form-item>
  159. <el-form-item label="对象ID 多个用,分隔" prop="companyId">
  160. <el-input v-model="form.companyId" placeholder="请输入对象ID 多个用,分隔" />
  161. </el-form-item>
  162. </el-form>
  163. <div slot="footer" class="dialog-footer">
  164. <el-button type="primary" @click="submitForm">确 定</el-button>
  165. <el-button @click="cancel">取 消</el-button>
  166. </div>
  167. </el-dialog>
  168. </div>
  169. </template>
  170. <script>
  171. import { listMsg, getMsg, delMsg, addMsg, updateMsg, exportMsg } from "@/api/crm/msg";
  172. import Editor from '@/components/Editor';
  173. export default {
  174. name: "Msg",
  175. components: { Editor },
  176. data() {
  177. return {
  178. // 遮罩层
  179. loading: true,
  180. // 选中数组
  181. ids: [],
  182. // 非单个禁用
  183. single: true,
  184. // 非多个禁用
  185. multiple: true,
  186. // 显示搜索条件
  187. showSearch: true,
  188. // 总条数
  189. total: 0,
  190. // 消息表格数据
  191. msgList: [],
  192. // 弹出层标题
  193. title: "",
  194. // 是否显示弹出层
  195. open: false,
  196. // 查询参数
  197. queryParams: {
  198. pageNum: 1,
  199. pageSize: 10,
  200. companyUserId: null,
  201. msgType: null,
  202. title: null,
  203. content: null,
  204. objId: null,
  205. isRead: null,
  206. companyId: null
  207. },
  208. // 表单参数
  209. form: {},
  210. // 表单校验
  211. rules: {
  212. }
  213. };
  214. },
  215. created() {
  216. this.getList();
  217. },
  218. methods: {
  219. /** 查询 消息列表 */
  220. getList() {
  221. this.loading = true;
  222. listMsg(this.queryParams).then(response => {
  223. this.msgList = response.rows;
  224. this.total = response.total;
  225. this.loading = false;
  226. });
  227. },
  228. // 取消按钮
  229. cancel() {
  230. this.open = false;
  231. this.reset();
  232. },
  233. // 表单重置
  234. reset() {
  235. this.form = {
  236. msgId: null,
  237. companyUserId: null,
  238. msgType: null,
  239. title: null,
  240. content: null,
  241. createTime: null,
  242. objId: null,
  243. isRead: null,
  244. companyId: null
  245. };
  246. this.resetForm("form");
  247. },
  248. /** 搜索按钮操作 */
  249. handleQuery() {
  250. this.queryParams.pageNum = 1;
  251. this.getList();
  252. },
  253. /** 重置按钮操作 */
  254. resetQuery() {
  255. this.resetForm("queryForm");
  256. this.handleQuery();
  257. },
  258. // 多选框选中数据
  259. handleSelectionChange(selection) {
  260. this.ids = selection.map(item => item.msgId)
  261. this.single = selection.length!==1
  262. this.multiple = !selection.length
  263. },
  264. /** 新增按钮操作 */
  265. handleAdd() {
  266. this.reset();
  267. this.open = true;
  268. this.title = "添加 消息";
  269. },
  270. /** 修改按钮操作 */
  271. handleUpdate(row) {
  272. this.reset();
  273. const msgId = row.msgId || this.ids
  274. getMsg(msgId).then(response => {
  275. this.form = response.data;
  276. this.open = true;
  277. this.title = "修改 消息";
  278. });
  279. },
  280. /** 提交按钮 */
  281. submitForm() {
  282. this.$refs["form"].validate(valid => {
  283. if (valid) {
  284. if (this.form.msgId != null) {
  285. updateMsg(this.form).then(response => {
  286. if (response.code === 200) {
  287. this.msgSuccess("修改成功");
  288. this.open = false;
  289. this.getList();
  290. }
  291. });
  292. } else {
  293. addMsg(this.form).then(response => {
  294. if (response.code === 200) {
  295. this.msgSuccess("新增成功");
  296. this.open = false;
  297. this.getList();
  298. }
  299. });
  300. }
  301. }
  302. });
  303. },
  304. /** 删除按钮操作 */
  305. handleDelete(row) {
  306. const msgIds = row.msgId || this.ids;
  307. this.$confirm('是否确认删除 消息编号为"' + msgIds + '"的数据项?', "警告", {
  308. confirmButtonText: "确定",
  309. cancelButtonText: "取消",
  310. type: "warning"
  311. }).then(function() {
  312. return delMsg(msgIds);
  313. }).then(() => {
  314. this.getList();
  315. this.msgSuccess("删除成功");
  316. }).catch(function() {});
  317. },
  318. /** 导出按钮操作 */
  319. handleExport() {
  320. const queryParams = this.queryParams;
  321. this.$confirm('是否确认导出所有 消息数据项?', "警告", {
  322. confirmButtonText: "确定",
  323. cancelButtonText: "取消",
  324. type: "warning"
  325. }).then(function() {
  326. return exportMsg(queryParams);
  327. }).then(response => {
  328. this.download(response.msg);
  329. }).catch(function() {});
  330. }
  331. }
  332. };
  333. </script>