index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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="companyUserName">
  5. <el-input
  6. v-model="queryParams.companyUserName"
  7. placeholder="请输入"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="账号" prop="account">
  14. <el-input
  15. v-model="queryParams.account"
  16. placeholder="请输入"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="消息编号" prop="id">
  23. <el-input
  24. v-model="queryParams.id"
  25. placeholder="请输入"
  26. clearable
  27. size="small"
  28. @keyup.enter.native="handleQuery"
  29. />
  30. </el-form-item>
  31. <el-form-item label="发送时间" prop="createTimeRange">
  32. <el-date-picker
  33. style="width:205.4px"
  34. clearable size="small"
  35. v-model="createTimeRange"
  36. type="daterange"
  37. value-format="yyyy-MM-dd"
  38. start-placeholder="开始日期"
  39. end-placeholder="结束日期">
  40. </el-date-picker>
  41. </el-form-item>
  42. <el-form-item>
  43. <el-button type="cyan" 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-button
  50. type="danger"
  51. icon="el-icon-delete"
  52. size="mini"
  53. :disabled="multiple"
  54. @click="handleDelete"
  55. v-hasPermi="['qw:forbiddenMessage:remove']"
  56. >删除</el-button>
  57. </el-col>
  58. <el-col :span="1.5">
  59. <el-button
  60. type="warning"
  61. icon="el-icon-download"
  62. size="mini"
  63. @click="handleExport"
  64. v-hasPermi="['qw:forbiddenMessage:export']"
  65. >导出</el-button>
  66. </el-col>
  67. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  68. </el-row>
  69. <el-table v-loading="loading" border :data="forbiddenMessageList" @selection-change="handleSelectionChange">
  70. <el-table-column type="selection" width="40" align="center" />
  71. <el-table-column label="公司" width="200" align="center" prop="companyName" />
  72. <el-table-column label="员工" width="100" align="center" prop="companyUserName" />
  73. <el-table-column label="发送时间" width="200" align="center" prop="sendTime">
  74. <template slot-scope="scope">
  75. {{ convertTimestampToTime(scope.row.sendTime) }}
  76. </template>
  77. </el-table-column>
  78. <el-table-column label="提示" align="center" prop="forbiddenMessage">
  79. <template slot-scope="scope">
  80. <div style="font-size: 16px; color: red;">
  81. {{ scope.row.forbiddenMessage }}
  82. </div>
  83. </template>
  84. </el-table-column>
  85. <el-table-column label="操作" width="100" align="center" class-name="small-padding fixed-width">
  86. <template slot-scope="scope">
  87. <el-button
  88. size="mini"
  89. type="text"
  90. @click="handleUpdate(scope.row)"
  91. v-hasPermi="['qw:forbiddenMessage:edit']"
  92. >查看</el-button>
  93. </template>
  94. </el-table-column>
  95. </el-table>
  96. <pagination
  97. v-show="total>0"
  98. :total="total"
  99. :page.sync="queryParams.pageNum"
  100. :limit.sync="queryParams.pageSize"
  101. @pagination="getList"
  102. />
  103. <!-- 添加或修改企微违禁消息对话框 -->
  104. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  105. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  106. <el-form-item label="消息id" prop="messageId">
  107. <el-input v-model="form.messageId" placeholder="请输入消息id" />
  108. </el-form-item>
  109. <el-form-item label="会话id" prop="conversationId">
  110. <el-input v-model="form.conversationId" placeholder="请输入会话id" />
  111. </el-form-item>
  112. <el-form-item label="消息体">
  113. <editor v-model="form.content" :min-height="192"/>
  114. </el-form-item>
  115. <el-form-item label="员工id" prop="companyUserId">
  116. <el-input v-model="form.companyUserId" placeholder="请输入员工id" />
  117. </el-form-item>
  118. <el-form-item label="公司id" prop="companyId">
  119. <el-input v-model="form.companyId" placeholder="请输入公司id" />
  120. </el-form-item>
  121. </el-form>
  122. <div slot="footer" class="dialog-footer">
  123. <el-button type="primary" @click="submitForm">确 定</el-button>
  124. <el-button @click="cancel">取 消</el-button>
  125. </div>
  126. </el-dialog>
  127. </div>
  128. </template>
  129. <script>
  130. import { listForbiddenMessage, getForbiddenMessage, delForbiddenMessage, addForbiddenMessage, updateForbiddenMessage, exportForbiddenMessage } from "@/api/qw/forbiddenMessage";
  131. import Editor from '@/components/Editor';
  132. export default {
  133. name: "ForbiddenMessage",
  134. components: { Editor },
  135. data() {
  136. return {
  137. // 遮罩层
  138. loading: true,
  139. // 选中数组
  140. ids: [],
  141. companys:[],
  142. createTimeRange:[],
  143. // 非单个禁用
  144. single: true,
  145. // 非多个禁用
  146. multiple: true,
  147. // 显示搜索条件
  148. showSearch: true,
  149. // 总条数
  150. total: 0,
  151. // 企微违禁消息表格数据
  152. forbiddenMessageList: [],
  153. // 弹出层标题
  154. title: "",
  155. // 是否显示弹出层
  156. open: false,
  157. // 查询参数
  158. queryParams: {
  159. pageNum: 1,
  160. pageSize: 10,
  161. messageId: null,
  162. conversationId: null,
  163. content: null,
  164. companyUserId: null,
  165. companyId: null,
  166. },
  167. // 表单参数
  168. form: {},
  169. // 表单校验
  170. rules: {
  171. }
  172. };
  173. },
  174. created() {
  175. this.getList();
  176. },
  177. methods: {
  178. convertTimestampToTime(timestamp) {
  179. const milliseconds = timestamp * 1000; // 将时间戳乘以1000以转换为毫秒
  180. // 创建一个新的Date对象,并将时间戳作为参数传入构造函数
  181. const date = new Date(milliseconds);
  182. // 使用Date对象的方法获取日期和时间
  183. const year = date.getFullYear();
  184. const month = date.getMonth() + 1;
  185. const day = date.getDate();
  186. const hours = date.getHours();
  187. const minutes = date.getMinutes();
  188. const seconds = date.getSeconds();
  189. // 返回转换后的日期和时间字符串
  190. return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  191. },
  192. /** 查询企微违禁消息列表 */
  193. getList() {
  194. this.loading = true;
  195. if(this.createTimeRange!=null&&this.createTimeRange.length==2){
  196. this.queryParams.createTimeRange=this.createTimeRange[0]+"--"+this.createTimeRange[1]
  197. }
  198. else{
  199. this.queryParams.createTimeRange=null;
  200. }
  201. listForbiddenMessage(this.queryParams).then(response => {
  202. this.forbiddenMessageList = response.rows;
  203. this.total = response.total;
  204. this.loading = false;
  205. });
  206. },
  207. // 取消按钮
  208. cancel() {
  209. this.open = false;
  210. this.reset();
  211. },
  212. // 表单重置
  213. reset() {
  214. this.form = {
  215. id: null,
  216. messageId: null,
  217. conversationId: null,
  218. content: null,
  219. companyUserId: null,
  220. companyId: null,
  221. createTime: null
  222. };
  223. this.resetForm("form");
  224. },
  225. /** 搜索按钮操作 */
  226. handleQuery() {
  227. this.queryParams.pageNum = 1;
  228. this.getList();
  229. },
  230. /** 重置按钮操作 */
  231. resetQuery() {
  232. this.resetForm("queryForm");
  233. this.handleQuery();
  234. },
  235. // 多选框选中数据
  236. handleSelectionChange(selection) {
  237. this.ids = selection.map(item => item.id)
  238. this.single = selection.length!==1
  239. this.multiple = !selection.length
  240. },
  241. /** 新增按钮操作 */
  242. handleAdd() {
  243. this.reset();
  244. this.open = true;
  245. this.title = "添加企微违禁消息";
  246. },
  247. /** 修改按钮操作 */
  248. handleUpdate(row) {
  249. this.reset();
  250. const id = row.id || this.ids
  251. getForbiddenMessage(id).then(response => {
  252. this.form = response.data;
  253. this.open = true;
  254. this.title = "修改企微违禁消息";
  255. });
  256. },
  257. /** 提交按钮 */
  258. submitForm() {
  259. this.$refs["form"].validate(valid => {
  260. if (valid) {
  261. if (this.form.id != null) {
  262. updateForbiddenMessage(this.form).then(response => {
  263. if (response.code === 200) {
  264. this.msgSuccess("修改成功");
  265. this.open = false;
  266. this.getList();
  267. }
  268. });
  269. } else {
  270. addForbiddenMessage(this.form).then(response => {
  271. if (response.code === 200) {
  272. this.msgSuccess("新增成功");
  273. this.open = false;
  274. this.getList();
  275. }
  276. });
  277. }
  278. }
  279. });
  280. },
  281. /** 删除按钮操作 */
  282. handleDelete(row) {
  283. const ids = row.id || this.ids;
  284. this.$confirm('是否确认删除企微违禁消息编号为"' + ids + '"的数据项?', "警告", {
  285. confirmButtonText: "确定",
  286. cancelButtonText: "取消",
  287. type: "warning"
  288. }).then(function() {
  289. return delForbiddenMessage(ids);
  290. }).then(() => {
  291. this.getList();
  292. this.msgSuccess("删除成功");
  293. }).catch(function() {});
  294. },
  295. /** 导出按钮操作 */
  296. handleExport() {
  297. const queryParams = this.queryParams;
  298. this.$confirm('是否确认导出所有企微违禁消息数据项?', "警告", {
  299. confirmButtonText: "确定",
  300. cancelButtonText: "取消",
  301. type: "warning"
  302. }).then(function() {
  303. return exportForbiddenMessage(queryParams);
  304. }).then(response => {
  305. this.download(response.msg);
  306. }).catch(function() {});
  307. }
  308. }
  309. };
  310. </script>