index.vue 17 KB

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