index.vue 12 KB

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