index.vue 12 KB

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