index.vue 12 KB

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