message.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. <template>
  2. <PageMain class="vh100">
  3. <el-form label-position="left" label-width="auto">
  4. <el-row :gutter="24">
  5. <el-col :span="6">
  6. <el-form-item label="消息内容">
  7. <el-input v-model="form.searchValue" placeholder="输入消息标题,内容" :prefix-icon="Search" />
  8. </el-form-item>
  9. </el-col>
  10. <el-col :span="6">
  11. <el-form-item label="发布机构">
  12. <el-cascader clearable style="width: 100%" v-model="form.sendDeptId" :options="institutionList"
  13. :props="tableProps" />
  14. </el-form-item>
  15. </el-col>
  16. <el-col :span="4">
  17. <el-form-item label="">
  18. <el-button type="primary" @click="getContentList">查询</el-button>
  19. <el-button type="primary" plain @click="reset">重置</el-button>
  20. </el-form-item>
  21. </el-col>
  22. </el-row>
  23. </el-form>
  24. <Table height="calc(100% - 56px)" :tableData="tableData" :columns="columns" :showIndex="false" :showSelect="false" :showOperation="true"
  25. :pageInfo="pageInfo" @getList="getList" :treeProps="{ children: 'children', hasChildren: 'hasChildren' }"
  26. @select-all-change="selectAllChange" @select-change="selectChange">
  27. <template v-slot:table-title-btn>
  28. <div>
  29. <!-- <el-button type="primary" @click="add(ruleFormRef)">
  30. <el-icon><Plus /></el-icon>添加机构</el-button
  31. > -->
  32. <el-button @click="router.push({ path: '/content/message/messageEdit' })"><el-icon>
  33. <Position />
  34. </el-icon>发布新的通知</el-button>
  35. </div>
  36. </template>
  37. <template v-slot:operation="scope">
  38. <el-button type="primary" link @click="editor(scope.operationData.row)">
  39. 编辑
  40. </el-button>
  41. <el-button type="primary" link @click="del(scope.operationData.row)">
  42. 删除
  43. </el-button>
  44. </template>
  45. <template v-slot:search="scope">
  46. {{ scope.slotData.label }}
  47. </template>
  48. </Table>
  49. </PageMain>
  50. <el-dialog v-model="dialogVisible" title="查看人数" width="1000">
  51. <Table :tableData="userTableData" :columns="userColumns" :showIndex="false" :showSelect="false"
  52. :showOperation="false" :pageInfo="userPageInfo" @getList="userGetList"
  53. :treeProps="{ children: 'children', hasChildren: 'hasChildren' }">
  54. </Table>
  55. </el-dialog>
  56. </template>
  57. <script setup lang="ts">
  58. import { ref, reactive, watch, onMounted } from "vue";
  59. import { Plus, Search, Position } from "@element-plus/icons-vue";
  60. import { useRouter } from "vue-router";
  61. // import universalTable from "../"
  62. import { ElMessageBox, ElTree, ElMessage } from "element-plus";
  63. import api from "@/api";
  64. import { h } from "vue";
  65. const router = useRouter();
  66. const filterText = ref("");
  67. const treeRef = ref<InstanceType<typeof ElTree>>();
  68. const dialogVisible = ref(false);
  69. //批量设置负责人
  70. watch(filterText, (val) => {
  71. treeRef.value!.filter(val);
  72. });
  73. let form = reactive({
  74. searchValue: "", //信息
  75. sendDeptId: "", //机构id
  76. });
  77. interface PageInfo {
  78. pageNum: number;
  79. pageSize: number;
  80. sizes: number[];
  81. total: number;
  82. show: boolean;
  83. }
  84. // import Select from "@/components/select/selectMain.vue";
  85. // import TestTable from "@/components/Table/index.vue";
  86. //业务员列表
  87. type tableType = {
  88. id: string;
  89. name: string;
  90. };
  91. const tableData = ref<tableType[]>([]);
  92. const userTableData = ref<tableType[]>([]);
  93. const tableProps = ref({
  94. value: "id",
  95. label: "name",
  96. children: "children",
  97. checkStrictly: true,
  98. });
  99. const typeformatter = (row: any, column: any, cellValue: any) => {
  100. return () =>
  101. h("div", null, [
  102. h(
  103. "h4",
  104. {
  105. onClick: () =>
  106. router.push({
  107. path: "/content/message/messageEdit",
  108. query: {
  109. id: row.id,
  110. },
  111. }),
  112. },
  113. row.title
  114. ),
  115. h("p", { class: "content" }, row.content),
  116. h("p", { class: "time" }, [
  117. h("span", null, row.createBy),
  118. h("span", null, "|"),
  119. h("span", null, row.createTime),
  120. ]),
  121. ]);
  122. };
  123. const columns = [
  124. { prop: "name", label: "发布消息", formatter: typeformatter, width: 500 },
  125. { prop: "sendDeptName", label: "发布机构" },
  126. // { prop: "id", label: "工号" },
  127. {
  128. prop: "isChildren",
  129. label: "下级机构是否发布",
  130. formatter: (row: any, column: any, cellValue: any) => {
  131. return () => h("div", {}, row.isChildren == "1" ? "是" : "否");
  132. },
  133. },
  134. {
  135. prop: "username",
  136. label: "是否强制查看",
  137. formatter: (row: any, column: any, cellValue: any) => {
  138. return () => h("div", {}, row.isForce == "1" ? "是" : "否");
  139. },
  140. },
  141. {
  142. prop: "viewCount",
  143. label: "查看人数",
  144. formatter: (row: any, column: any, cellValue: any) => {
  145. return () =>
  146. h(
  147. "h4",
  148. { class: "count", onClick: () => openDialog(row) },
  149. row.viewCount
  150. );
  151. },
  152. },
  153. ];
  154. const userColumns = [
  155. { prop: "name", label: "业务员姓名" },
  156. { prop: "mobile", label: "业务员手机号" },
  157. // { prop: "id", label: "工号" },
  158. {
  159. prop: "userId",
  160. label: "工号",
  161. },
  162. {
  163. prop: "deptName",
  164. label: "所属机构",
  165. },
  166. {
  167. prop: "createTime",
  168. label: "查看时间",
  169. },
  170. ];
  171. const contentId = ref("");
  172. function openDialog(item: any) {
  173. contentId.value = item.id;
  174. dialogVisible.value = true;
  175. userTableData.value = []
  176. getContenUser();
  177. }
  178. function getContenUser() {
  179. api.contentApi
  180. .contentUserList({
  181. id: contentId.value,
  182. ...userPageInfo,
  183. })
  184. .then((res: any) => {
  185. if (res.code === 200) {
  186. userTableData.value = res.data.records;
  187. userPageInfo.total = res.data.total;
  188. }
  189. });
  190. }
  191. const pageInfo = {
  192. pageNum: 1,
  193. pageSize: 10,
  194. sizes: [10, 20, 30, 40, 50],
  195. total: 0,
  196. show: true,
  197. };
  198. const userPageInfo = {
  199. pageNum: 1,
  200. pageSize: 10,
  201. sizes: [10, 20, 30, 40, 50],
  202. total: 0,
  203. show: true,
  204. };
  205. //分页列表功能
  206. const getList = (item: PageInfo) => {
  207. pageInfo.pageNum = item.pageNum;
  208. pageInfo.pageSize = item.pageSize;
  209. getContentList();
  210. };
  211. //分页列表功能
  212. const userGetList = (item: PageInfo) => {
  213. userPageInfo.pageNum = item.pageNum;
  214. userPageInfo.pageSize = item.pageSize;
  215. getContenUser();
  216. };
  217. const checkTableIdList = ref([]);
  218. //表格选择事件
  219. function selectAllChange(list: any) {
  220. checkTableIdList.value = list;
  221. }
  222. function selectChange(list: any) {
  223. checkTableIdList.value = list;
  224. }
  225. //机构列表
  226. const institutionList = ref([]);
  227. const getInstitutionList = () => {
  228. api.institutionApi.institutionList({}).then((res: any) => {
  229. if (res.code === 200) institutionList.value = res.data;
  230. });
  231. };
  232. const getContentList = () => {
  233. api.contentApi
  234. .noticeList({
  235. ...form,
  236. ...pageInfo,
  237. })
  238. .then((res: any) => {
  239. if (res.code === 200) {
  240. tableData.value = res.data.records;
  241. pageInfo.total = res.data.total;
  242. }
  243. });
  244. // pageInfo.pageSize=item.pageSize
  245. };
  246. function editor(item: any) {
  247. router.push({
  248. path: "/content/message/messageEdit",
  249. query: {
  250. id: item.id,
  251. },
  252. });
  253. }
  254. function del(item: any) {
  255. ElMessageBox.confirm("确认要删除当前数据吗?", "提示", {
  256. confirmButtonText: "确认",
  257. cancelButtonText: "取消",
  258. type: "warning",
  259. center: true,
  260. })
  261. .then(() => {
  262. api.contentApi.noticeDelete([item.id]).then((res) => {
  263. if (res.code === 200) {
  264. ElMessage.success("操作成功");
  265. getContentList();
  266. }
  267. });
  268. })
  269. .catch(() => {
  270. ElMessage.warning("用户取消操作");
  271. });
  272. }
  273. const reset = (item: any) => {
  274. // ElMessage({})
  275. form.searchValue = ''
  276. form.sendDeptId = ''
  277. getContentList()
  278. };
  279. onMounted(() => {
  280. getContentList();
  281. getInstitutionList(); //机构列表
  282. });
  283. </script>
  284. <style lang="scss" scoped>
  285. :deep(.count) {
  286. margin: 0 !important;
  287. color: #409eff;
  288. cursor: pointer;
  289. }
  290. :deep(.routerlick) {
  291. h4 {
  292. margin: 0 !important;
  293. color: #409eff;
  294. cursor: pointer;
  295. }
  296. p {
  297. margin: 0 !important;
  298. }
  299. .content {
  300. // width: 200px;
  301. // background-color: hotpink;
  302. // padding: 5px 10px;
  303. overflow: hidden;
  304. text-overflow: ellipsis;
  305. display: -webkit-box;
  306. -webkit-line-clamp: 2;
  307. line-clamp: 2;
  308. -webkit-box-orient: vertical;
  309. }
  310. .time {
  311. display: flex;
  312. >span {
  313. flex: none;
  314. display: flex;
  315. }
  316. >span:nth-child(2) {
  317. margin: 0 20px;
  318. }
  319. }
  320. }
  321. :deep(.table-title-btn) {
  322. display: flex;
  323. align-items: center;
  324. justify-content: space-between;
  325. >div {
  326. display: flex;
  327. }
  328. }
  329. :deep(.el-dropdown-link) {
  330. cursor: pointer;
  331. color: var(--el-color-primary);
  332. display: flex;
  333. align-items: center;
  334. margin-left: 15px;
  335. }
  336. .custom-tree-node {
  337. flex: 1;
  338. display: flex;
  339. align-items: center;
  340. justify-content: space-between;
  341. font-size: 14px;
  342. padding-right: 8px;
  343. }
  344. :deep(.el-message-box__container) {
  345. width: 100% !important;
  346. .el-message-box__message {
  347. width: 100% !important;
  348. }
  349. }
  350. </style>