index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="20">
  4. <el-col :span="4" :xs="24">
  5. <org-tree v-model="queryParams.orgId" @defaultKey="getDefaultKey" @checkChange="checkChange"
  6. @click="clickTreeNode"></org-tree>
  7. </el-col>
  8. <el-col :span="20" :xs="24">
  9. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  10. <el-form-item label="关键字" prop="title">
  11. <el-input v-model="queryParams.title" placeholder="请输入关键字" />
  12. </el-form-item>
  13. <el-form-item label="发布时间" prop="planStartTime">
  14. <el-date-picker
  15. v-model="queryParams.dateRange"
  16. style="width: 240px"
  17. value-format="yyyy-MM-dd HH:mm:ss"
  18. type="daterange"
  19. range-separator="-"
  20. start-placeholder="开始日期"
  21. end-placeholder="结束日期"
  22. :default-time="['00:00:00', '23:59:59']"
  23. ></el-date-picker>
  24. </el-form-item>
  25. <el-form-item label="状态" prop="messagStatus">
  26. <el-select v-model="queryParams.messagStatus" placeholder="请选择状态" clearable>
  27. <el-option
  28. v-for="dict in dict.type.message_status"
  29. :key="dict.value"
  30. :label="dict.label"
  31. :value="dict.value"
  32. />
  33. </el-select>
  34. </el-form-item>
  35. <el-form-item>
  36. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  37. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  38. </el-form-item>
  39. </el-form>
  40. <el-row :gutter="10" class="mb8">
  41. <el-col :span="1.5">
  42. <el-button
  43. type="primary"
  44. plain
  45. icon="el-icon-plus"
  46. size="mini"
  47. @click="handleAdd"
  48. v-hasPermi="['core:notification:add']"
  49. >新增</el-button>
  50. </el-col>
  51. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  52. </el-row>
  53. <el-table v-loading="loading" :data="notificationList"border
  54. height="600"
  55. size="small">
  56. <el-table-column label="序号" type="index" align="center">
  57. <template slot-scope="scope">
  58. <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
  59. </template>
  60. </el-table-column>
  61. <el-table-column label="创建机构" align="center" width="160" prop="orgName" />
  62. <el-table-column label="消息类型" align="center" prop="messagType">
  63. <template slot-scope="scope">
  64. <dict-tag :options="dict.type.messag_type" :value="scope.row.messagType"/>
  65. </template>
  66. </el-table-column>
  67. <el-table-column label="机构类型" align="center" prop="execOrgType">
  68. <template slot-scope="scope">
  69. <dict-tag :options="dict.type.sys_org_type" :value="scope.row.tagOrgType"/>
  70. </template>
  71. </el-table-column>
  72. <el-table-column prop="tagRoleIds" width="180" label="目标角色">
  73. <template slot-scope="r">
  74. <span>{{getRolename(r.row.tagRoleIds)}}</span>
  75. </template>
  76. </el-table-column>
  77. <el-table-column label="标题" align="center" width="200" prop="title" >
  78. <template slot-scope="r"><p :title="r.row.title" class="line-style">{{r.row.title}}</p></template>
  79. </el-table-column>
  80. <el-table-column label="创建人" align="center" prop="createBy" />
  81. <el-table-column label="发布时间" align="center" prop="publishTime" width="180">
  82. <!-- <template slot-scope="scope">
  83. <span>{{ parseTime(scope.row.publishTime, '{y}-{m}-{d}') }}</span>
  84. </template>-->
  85. </el-table-column>
  86. <el-table-column label="状态" align="center" prop="messagStatus">
  87. <template slot-scope="scope">
  88. <dict-tag :options="dict.type.message_status" :value="scope.row.messagStatus"/>
  89. </template>
  90. </el-table-column>
  91. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  92. <template slot-scope="scope">
  93. <el-button
  94. size="mini"
  95. type="text"
  96. @click="lookThisOne(scope.row)"
  97. v-hasPermi="['core:notification:query']"
  98. >详情</el-button>
  99. <div v-if="loginOrgId==scope.row.orgId">
  100. <el-button
  101. size="mini"
  102. type="text"
  103. @click="handleUpdate(scope.row)"
  104. v-hasPermi="['core:notification:edit']"
  105. v-if="scope.row.messagStatus=='0'"
  106. >编辑</el-button>
  107. <el-button
  108. size="mini"
  109. type="text"
  110. @click="handleDelete(scope.row)"
  111. v-hasPermi="['core:notification:remove']"
  112. v-if="scope.row.messagStatus=='0'"
  113. >删除</el-button>
  114. <el-button
  115. size="mini"
  116. type="text"
  117. @click="publish(scope.row)"
  118. v-hasPermi="['core:notification:publish']"
  119. v-if="scope.row.messagStatus=='0'"
  120. >发布</el-button>
  121. <el-button
  122. size="mini"
  123. type="text"
  124. @click="publish(scope.row)"
  125. v-hasPermi="['core:notification:cancelPublish']"
  126. v-if="scope.row.messagStatus=='1'"
  127. >取消发布</el-button>
  128. </div>
  129. </template>
  130. </el-table-column>
  131. </el-table>
  132. <pagination
  133. v-show="total>0"
  134. :total="total"
  135. :page.sync="queryParams.pageNum"
  136. :limit.sync="queryParams.pageSize"
  137. @pagination="getList"
  138. />
  139. </el-col>
  140. <!-- 添加或修改公告通知对话框 -->
  141. <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body @close="handleClose">
  142. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  143. <el-form-item label="标题" prop="title">
  144. <el-input v-model="form.title" placeholder="请输入标题" :disabled="!isSubmit" :maxlength="100"/>
  145. </el-form-item>
  146. <el-form-item label="消息类型" prop="messagType">
  147. <el-select v-model="form.messagType" placeholder="请选择消息类型" :disabled="!isSubmit" @change="showOrHidden()">
  148. <el-option
  149. v-for="dict in dict.type.messag_type"
  150. :key="dict.value"
  151. :label="dict.label"
  152. :value="dict.value"
  153. ></el-option>
  154. </el-select>
  155. </el-form-item>
  156. <el-form-item label="机构类型" prop="tagOrgType">
  157. <el-select v-model="form.tagOrgType" placeholder="请选择机构类型" :disabled="!isSubmit" @change="execOrgTypeChanged()">
  158. <el-option v-for="dict in dict.type.sys_org_type" :key="dict.value" :label="dict.label"
  159. :value="dict.value"></el-option>
  160. </el-select>
  161. </el-form-item>
  162. <el-form-item label="目标机构" prop="tagOrgIds">
  163. <!-- <org-tree-select :queryData="form.tagOrgType" ref="orgTreeSelect" @selectNode="queryNode"
  164. :placeholder="'请选择目标机构'" :disable="true"></org-tree-select>-->
  165. <org-tree-select
  166. v-model="form.tagOrgIds"
  167. :queryData="parseInt(form.tagOrgType)"
  168. ref="orgTreeSelect"
  169. :enabledCheckOrgTypes="parseInt(form.tagOrgType)"
  170. :disable="true" :disabled="!isSubmit">
  171. </org-tree-select>
  172. </el-form-item>
  173. <!-- </el-form-item>-->
  174. <el-form-item label="目标角色" v-if="isShow" prop="tagRoleIds">
  175. <el-select v-model="form.tagRoleIds" placeholder="请选择" :disabled="!isSubmit" multiple>
  176. <el-option v-for="item in roleList" :key="item.id" :label="item.name" :value="item.id"></el-option>
  177. </el-select>
  178. </el-form-item>
  179. <el-form-item label="内容" prop="content">
  180. <el-input v-model="form.content" type="textarea" placeholder="请输入内容" :disabled="!isSubmit" :autosize="{ minRows: 6, maxRows: 10}" :maxlength="2000" show-word-limit/>
  181. </el-form-item>
  182. <el-form-item label="附件" prop="fileList">
  183. <K-file-upload ref="upload" :defaultValue="formFileListDefualtValue" :disabled="!isSubmit" :isShowUploadBtn="!isSubmit? false:true" v-model="form.fileList"/>
  184. </el-form-item>
  185. </el-form>
  186. <div slot="footer" class="dialog-footer">
  187. <el-button type="primary" v-if="isSubmit" @click="submitForm">确 定</el-button>
  188. <el-button @click="cancel">取 消</el-button>
  189. </div>
  190. </el-dialog>
  191. </el-row>
  192. </div>
  193. </template>
  194. <script>
  195. import { listNotification, getNotification, delNotification, addNotification, updateNotification,roleList,publishNotification } from "@/api/core/notification";
  196. import OrgTree from "@/components/orgTree";
  197. import orgDropDown from "@/components/orgTree/orgDropDown.vue";
  198. import KFileUpload from "@/components/K-FileUpload/index.vue";
  199. import OrgTreeSelect from '@/components/orgTreeSelect'
  200. export default {
  201. components: {OrgTree,orgDropDown,KFileUpload,OrgTreeSelect},
  202. name: "Notification",
  203. dicts: ['messag_type', 'message_status','sys_org_type'],
  204. data() {
  205. return {
  206. // 遮罩层
  207. loading: true,
  208. // 选中数组
  209. ids: [],
  210. // 非单个禁用
  211. single: true,
  212. // 非多个禁用
  213. multiple: true,
  214. // 显示搜索条件
  215. showSearch: true,
  216. // 总条数
  217. total: 0,
  218. // 公告通知表格数据
  219. notificationList: [],
  220. // 弹出层标题
  221. title: "",
  222. // 是否显示弹出层
  223. open: false,
  224. orgId:null,
  225. loginOrgId:null,
  226. // 查询参数
  227. queryParams: {
  228. pageNum: 1,
  229. pageSize: 10,
  230. title: null,
  231. dateRange: [],
  232. messagStatus: null,
  233. checkSub:true
  234. },
  235. isShow:false,
  236. isSubmit:true,
  237. roleList: [],
  238. roleListInit: [],
  239. formFileListDefualtValue: [],
  240. // 表单参数
  241. form: {},
  242. // 表单校验
  243. rules: {
  244. title: [{ required: true, message: "请输入标题" }],
  245. messagType: [{ required: true, message: "请选择消息类型" }],
  246. tagOrgType: [{ required: true, message: "请选择机构类型" }],
  247. tagOrgIds: [{ required: true, message: "请选择目标机构" }],
  248. content: [{ required: true, message: "请输入内容" }],
  249. }
  250. };
  251. },
  252. created() {
  253. this.orgId = this.$store.getters.orgId;
  254. this.loginOrgId = this.$store.getters.orgId;
  255. this.queryParams.orgId = this.$store.getters.orgId;
  256. this.getList();
  257. this.initRoleList();
  258. },
  259. methods: {
  260. /** 查询公告通知列表 */
  261. getList() {
  262. this.loading = true;
  263. listNotification(this.queryParams).then(response => {
  264. this.notificationList = response.rows;
  265. this.total = response.total;
  266. this.loading = false;
  267. });
  268. },
  269. getRolename(roleIds){
  270. if(roleIds!=null && roleIds.length>0){
  271. return roleIds.map(v => {
  272. if(this.roleListInit.find(item => item.id === v)){
  273. return this.roleListInit.find(item => item.id === v).name
  274. }else {
  275. return "";
  276. }
  277. }).join(',');
  278. }else {
  279. return "";
  280. }
  281. },
  282. // 取消按钮
  283. cancel() {
  284. this.open = false;
  285. this.$refs.orgTreeSelect.clear();
  286. //this.roleList=[];
  287. this.reset();
  288. this.isSubmit=true;
  289. this.isShow=false;
  290. },
  291. handleClose(){
  292. this.cancel();
  293. },
  294. queryNode(nodes) {
  295. this.form.tagOrgIds = JSON.parse(nodes).map(v => {
  296. return v.id
  297. });
  298. },
  299. // 表单重置
  300. reset() {
  301. this.form = {
  302. id: null,
  303. orgId: null,
  304. orgName: null,
  305. orgPath: null,
  306. title: null,
  307. content: null,
  308. messagType: null,
  309. tagOrgIds: null,
  310. tagRoleIds: null,
  311. createBy: null,
  312. createTime: null,
  313. publishTime: null,
  314. messagStatus: null,
  315. fileList: []
  316. };
  317. this.resetForm("form");
  318. },
  319. /** 搜索按钮操作 */
  320. handleQuery() {
  321. this.queryParams.pageNum = 1;
  322. this.getList();
  323. },
  324. /** 重置按钮操作 */
  325. resetQuery() {
  326. this.resetForm("queryForm");
  327. this.queryParams.dateRange=[];
  328. this.handleQuery();
  329. },
  330. // 多选框选中数据
  331. handleSelectionChange(selection) {
  332. this.ids = selection.map(item => item.id)
  333. this.single = selection.length!==1
  334. this.multiple = !selection.length
  335. },
  336. /** 新增按钮操作 */
  337. handleAdd() {
  338. this.reset();
  339. this.initRoleList();
  340. this.formFileListDefualtValue=[];
  341. this.open = true;
  342. this.isShow=false;
  343. this.title = "添加公告通知";
  344. },
  345. /** 修改按钮操作 */
  346. handleUpdate(row) {
  347. this.reset();
  348. const id = row.id || this.ids
  349. getNotification(id).then(response => {
  350. this.form = response.data;
  351. if(this.form.tagRoleIds!=null&&this.form.tagRoleIds.length>0){
  352. this.isShow=true;
  353. }
  354. roleList(this.form.tagOrgType).then(res => {
  355. this.roleList = res.data;
  356. });
  357. this.formFileListDefualtValue = this.form.fileList;
  358. this.open = true;
  359. this.title = "修改公告通知";
  360. });
  361. },
  362. lookThisOne(row) {
  363. this.reset();
  364. this.isSubmit = false;
  365. const id = row.id || this.ids
  366. getNotification(id).then(response => {
  367. this.form = response.data;
  368. if(this.form.tagRoleIds!=null&&this.form.tagRoleIds.length>0){
  369. this.isShow=true;
  370. }
  371. roleList(this.form.tagOrgType).then(res => {
  372. this.roleList = res.data;
  373. });
  374. this.formFileListDefualtValue = this.form.fileList;
  375. this.open = true;
  376. this.title = "公告通知详情";
  377. });
  378. },
  379. /** 提交按钮 */
  380. submitForm() {
  381. this.form.orgId = this.orgId;
  382. this.$refs["form"].validate(valid => {
  383. if (valid) {
  384. if (this.form.id != null) {
  385. updateNotification(this.form).then(response => {
  386. this.$modal.msgSuccess("修改成功");
  387. this.open = false;
  388. this.$refs.orgTreeSelect.clear();
  389. this.reset();
  390. this.$refs["upload"].clearFiles();
  391. this.form.fileList=[];
  392. this.getList();
  393. });
  394. } else {
  395. addNotification(this.form).then(response => {
  396. this.$modal.msgSuccess("新增成功");
  397. this.open = false;
  398. this.$refs.orgTreeSelect.clear();
  399. this.reset();
  400. this.form.fileList=[];
  401. this.$refs["upload"].clearFiles();
  402. this.getList();
  403. });
  404. }
  405. }
  406. });
  407. },
  408. /** 删除按钮操作 */
  409. handleDelete(row) {
  410. const ids = row.id || this.ids;
  411. this.$modal.confirm('是否确认删除该公告通知?').then(function() {
  412. return delNotification(ids);
  413. }).then(() => {
  414. this.getList();
  415. this.$modal.msgSuccess("删除成功");
  416. }).catch(() => {});
  417. },
  418. publish(row){
  419. const id = row.id;
  420. const messagStatus = row.messagStatus;
  421. let message = "";
  422. let returnMessage = "";
  423. if(messagStatus==0){
  424. message="你确定要发布该消息吗?";
  425. returnMessage = "发布成功";
  426. }else{
  427. message="你确定要取消发布该消息吗?";
  428. returnMessage = "取消发布成功";
  429. }
  430. this.$modal.confirm(message).then(function() {
  431. return publishNotification(id);
  432. }).then(() => {
  433. this.getList();
  434. this.$modal.msgSuccess(returnMessage);
  435. }).catch(() => {});
  436. },
  437. getDefaultKey(key) {
  438. this.queryParams.orgId = key;
  439. this.getList();
  440. },
  441. checkChange(state) {
  442. this.queryParams.checkSub = state;
  443. this.handleQuery();
  444. },
  445. // 节点单击事件
  446. clickTreeNode(data) {
  447. this.queryParams.orgId = data.id;
  448. this.orgName = data.name;
  449. this.handleQuery();
  450. },
  451. execOrgTypeChanged(row) {
  452. this.form.tagRoleIds=[];
  453. this.$refs.orgTreeSelect.clear();
  454. this.initRoleList(this.form.tagOrgType);
  455. },
  456. initRoleList(query) {
  457. this.form.tagRoleIds = [];
  458. roleList(query).then(response => {
  459. this.roleList = response.data;
  460. this.roleListInit = response.data;
  461. });
  462. },
  463. showOrHidden(){
  464. if(this.form.messagType=='1'){
  465. this.isShow=true;
  466. }else {
  467. this.form.tagRoleIds = [];
  468. this.isShow=false;
  469. }
  470. },
  471. /** 下穿状态改变*/
  472. changeCheckBox() {
  473. this.getList();
  474. },
  475. }
  476. };
  477. </script>
  478. <style lang="scss" scoped>
  479. .line-style{
  480. display : -webkit-box;
  481. -webkit-line-clamp: 3 ; //限定显示行数
  482. -webkit-box-orient: vertical;
  483. overflow : hidden ;
  484. text-overflow: ellipsis;
  485. }
  486. </style>