index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. <!--信息发布-->
  2. <template>
  3. <div class="app-container content">
  4. <div class="content-page" v-if="pageType == 1">
  5. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  6. <el-form-item label="发送对象" prop="messClass">
  7. <el-select v-model="queryParams.messClass" clearable placeholder="请选择发送范围" size="small">
  8. <!-- <el-option label="请选择发送范围" value="" /> -->
  9. <el-option label="人员" value=1 />
  10. <el-option label="实验室" value=3 />
  11. </el-select>
  12. </el-form-item>
  13. <el-form-item label="发送人" prop="sendName">
  14. <el-input
  15. clearable
  16. v-model="queryParams.sendName"
  17. placeholder="请输入发送人"
  18. size="small"
  19. />
  20. </el-form-item>
  21. <el-form-item label="创建时间" prop="dateRange" style="margin-left:10px;">
  22. <el-date-picker
  23. :clearable="false"
  24. v-model="dateRange"
  25. size="small"
  26. style="width: 240px"
  27. value-format="yyyy-MM-dd"
  28. type="daterange"
  29. range-separator="-"
  30. start-placeholder="开始日期"
  31. end-placeholder="结束日期"
  32. ></el-date-picker>
  33. </el-form-item>
  34. <el-form-item >
  35. <p class="inquire-button-one" @click="handleQuery">查询</p>
  36. <p class="reset-button-one" @click="resetQuery">重置</p>
  37. </el-form-item>
  38. </el-form>
  39. <el-table v-loading="loading" border :data="contentList" @selection-change="handleSelectionChange">
  40. <el-table-column label="发送人" align="left" prop="sendName" />
  41. <el-table-column label="发送对象" align="left" prop="messClass">
  42. <template slot-scope="scope">{{scope.row.messClass==1?'人员':(scope.row.messClass==3?'实验室':'')}}</template>
  43. </el-table-column>
  44. <el-table-column label="发送时间" align="left" prop="createTime">
  45. <template slot-scope="scope">
  46. <span>{{ parseTime(scope.row.createTime) }}</span>
  47. </template>
  48. </el-table-column>
  49. <el-table-column label="操作" align="left" class-name="small-padding fixed-width" width="160" v-if="tableButtonType">
  50. <template slot-scope="scope">
  51. <div class="table-button-box">
  52. <p class="table-button-null"></p>
  53. <p class="table-button-p"
  54. @click="clickPage(2,scope.row)"
  55. v-hasPermi="['laboratory:content:query']"
  56. >查看</p>
  57. <p class="table-button-p"
  58. @click="handleDelete(scope.row)"
  59. v-hasPermi="['laboratory:content:remove']"
  60. >删除</p>
  61. <p class="table-button-null"></p>
  62. </div>
  63. </template>
  64. </el-table-column>
  65. </el-table>
  66. <pagination :page-sizes="[20, 30, 40, 50]"
  67. v-show="total>0"
  68. :total="total"
  69. layout="total, prev, pager, next, sizes, jumper"
  70. :page.sync="queryParams.pageNum"
  71. :limit.sync="queryParams.pageSize"
  72. @pagination="getList"
  73. />
  74. </div>
  75. <info-page v-if="pageType == 2" :infoData="infoData"></info-page>
  76. </div>
  77. </template>
  78. <script>
  79. import { listContent, getContent, delContent, addContent, updateContent, contentInfo } from "@/api/laboratory/content";
  80. import { selectListUser } from "@/api/system/user";
  81. import { treeselect as deptTreeselect} from "@/api/system/dept";
  82. import infoPage from "./infoPage.vue"
  83. export default {
  84. name: "Content",
  85. components: {
  86. infoPage
  87. },
  88. data() {
  89. var validateDepts = (rule, value, callback) => {
  90. let arr = this.$refs.dept.getCheckedKeys()
  91. if (arr.length == 0 || !arr) {
  92. callback(new Error("请选择学院"));
  93. } else {
  94. callback();
  95. }
  96. };
  97. return {
  98. tableButtonType:this.hasPermiDom(['laboratory:content:query','laboratory:content:remove']),
  99. pageType:1,
  100. // 遮罩层
  101. loading: true,
  102. // 选中数组
  103. ids: [],
  104. // 非单个禁用
  105. single: true,
  106. // 非多个禁用
  107. multiple: true,
  108. // 显示搜索条件
  109. showSearch: true,
  110. // 总条数
  111. total: 0,
  112. // 消息发布表格数据
  113. contentList: [],
  114. // 弹出层标题
  115. title: "",
  116. // 是否显示弹出层
  117. open: false,
  118. openTwo:false,
  119. // 查询参数
  120. queryParams: {
  121. pageNum: 1,
  122. pageSize:20,
  123. messType: null,
  124. sendMode: null,
  125. sendRange: null,
  126. content: null,
  127. deptId: null,
  128. deptName: null,
  129. userIds: null,
  130. userId: null,
  131. },
  132. dateRange:[],
  133. // 表单参数
  134. form: {},
  135. // 表单校验
  136. rules: {
  137. sendRange:[
  138. {required: true, message: '请选择发送范围', trigger: 'change'}
  139. ],
  140. deptName:[
  141. {required: true, validator: validateDepts, trigger: 'change'}
  142. ],
  143. userIds:[
  144. {required: true, message: '请选择人员', trigger: 'blur'}
  145. ],
  146. content:[
  147. {required: true, message: '请输入发送内容', trigger: 'blur'},
  148. { required: true, message: "请输入发送内容", validator: this.spaceJudgmentHTML, trigger: "blur" }
  149. ]
  150. },
  151. //选择部门
  152. optionsDepartment: [],
  153. //选择人员
  154. optionsUser: [],
  155. //人员下拉查询条件
  156. queryUserListParams : {
  157. nickName : undefined
  158. },
  159. defaultProps: {
  160. children: "children",
  161. label: "label"
  162. },
  163. infoData:{},
  164. };
  165. },
  166. created() {
  167. this.getList();
  168. this.getDeptTreeselect();
  169. },
  170. methods: {
  171. clickPage(type,row){
  172. if(this.pageType != type){
  173. if(type == 1){
  174. this.getList();
  175. this.pageType = 1;
  176. }else if(type == 2){
  177. contentInfo(row.id).then(response => {
  178. this.infoData = response.data;
  179. let text = ""
  180. if(response.data.deptName){
  181. text = text + response.data.deptName
  182. }
  183. if(response.data.postName){
  184. text = text + response.data.postName
  185. }
  186. if(response.data.userNames){
  187. text = text + response.data.userNames
  188. }
  189. this.infoData.typeText = text;
  190. this.pageType = 2
  191. });
  192. }
  193. }
  194. },
  195. /** 查询消息发布列表 */
  196. getList() {
  197. this.loading = true;
  198. if(this.dateRange&&this.dateRange.length>0) {
  199. this.queryParams.startDate=this.dateRange[0]
  200. this.queryParams.endDate=this.dateRange[1]
  201. } else {
  202. this.queryParams.startDate=null;
  203. this.queryParams.endDate=null
  204. }
  205. listContent(this.queryParams).then(response => {
  206. this.contentList = response.rows;
  207. this.total = response.total;
  208. this.loading = false;
  209. });
  210. },
  211. // 取消按钮
  212. cancel() {
  213. this.open = false;
  214. this.reset();
  215. },
  216. // 表单重置
  217. reset() {
  218. this.form = {
  219. id: null,
  220. messType: null,
  221. sendMode: null,
  222. sendRange: null,
  223. content: null,
  224. deptIds: null,
  225. deptName: null,
  226. userIds: null,
  227. createTime: null,
  228. userId: null,
  229. createBy: null,
  230. updateTime: null,
  231. updateBy: null,
  232. remark: null
  233. };
  234. this.resetForm("form");
  235. },
  236. /** 搜索按钮操作 */
  237. handleQuery() {
  238. this.queryParams.pageNum = 1;
  239. this.getList();
  240. },
  241. /** 重置按钮操作 */
  242. resetQuery() {
  243. this.dateRange = [];
  244. // this.resetForm("queryForm");
  245. this.$set(this,'queryParams',{
  246. pageNum: 1,
  247. pageSize:20,
  248. messClass:"",
  249. sendName: '',
  250. });
  251. this.handleQuery();
  252. },
  253. // 多选框选中数据
  254. handleSelectionChange(selection) {
  255. this.ids = selection.map(item => item.id)
  256. this.single = selection.length!==1
  257. this.multiple = !selection.length
  258. },
  259. /** 新增按钮操作 */
  260. handleAdd() {
  261. this.reset();
  262. this.open = true;
  263. this.title = "消息发布";
  264. },
  265. /** 修改按钮操作 */
  266. handleUpdate(row) {
  267. this.reset();
  268. const id = row.id || this.ids
  269. getContent(id).then(response => {
  270. this.form = response.data;
  271. this.open = true;
  272. this.title = "修改消息发布";
  273. });
  274. },
  275. /** 提交按钮 */
  276. submitForm() {
  277. this.$refs["form"].validate(valid => {
  278. if (valid) {
  279. if(this.form.sendRange==2)
  280. {
  281. this.form.deptIds = this.getDeptAllCheckedKeys().join();
  282. }else if(this.form.sendRange==3)
  283. {
  284. this.form.userIds= this.form.userIds.join();
  285. }
  286. if (this.form.id != null) {
  287. this.form.content = escape(this.form.content);
  288. console.log(this.form.content);
  289. updateContent(this.form).then(response => {
  290. this.msgSuccess("修改成功");
  291. this.open = false;
  292. this.getList();
  293. });
  294. } else {
  295. this.form.content = escape(this.form.content);
  296. console.log(this.form.content);
  297. addContent(this.form).then(response => {
  298. this.msgSuccess("新增成功");
  299. this.open = false;
  300. this.getList();
  301. });
  302. this.form.content = unescape(this.form.content);
  303. }
  304. }
  305. });
  306. },
  307. /** 删除按钮操作 */
  308. handleDelete(row) {
  309. const ids = row.id || this.ids;
  310. this.$confirm('是否确认删除?', "警告", {
  311. confirmButtonText: "确定",
  312. cancelButtonText: "取消",
  313. type: "warning"
  314. }).then(function() {
  315. return delContent(ids);
  316. }).then(() => {
  317. this.getList();
  318. this.msgSuccess("删除成功");
  319. }).catch(() => {});
  320. },
  321. /** 导出按钮操作 */
  322. handleExport() {
  323. this.download('laboratory/content/export', {
  324. ...this.queryParams
  325. }, `laboratory_content.xlsx`)
  326. },
  327. /** 下列人员-懒加载 */
  328. userSelectList(query) {
  329. if (query !== '' && query.length>1) {
  330. this.loading = true;
  331. this.userSelectList.nickName=query;
  332. selectListUser(this.userSelectList).then(response => {
  333. this.optionsUser = response.data;
  334. this.loading = false;
  335. });
  336. } else {
  337. this.optionsUser = [];
  338. }
  339. }
  340. ,
  341. // 树权限(父子联动)
  342. handleCheckedTreeConnect(value) {
  343. this.form.deptCheckStrictly = value ? true: false;
  344. },
  345. /** 查询部门树结构 */
  346. getDeptTreeselect() {
  347. deptTreeselect().then(response => {
  348. this.optionsDepartment = response.data;
  349. });
  350. },
  351. // 所有部门节点数据
  352. getDeptAllCheckedKeys() {
  353. // 目前被选中的部门节点
  354. let checkedKeys = this.$refs.dept.getCheckedKeys();
  355. // 半选中的部门节点
  356. let halfCheckedKeys = this.$refs.dept.getHalfCheckedKeys();
  357. checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys);
  358. return checkedKeys;
  359. },
  360. }
  361. };
  362. </script>
  363. <style scoped lang="scss">
  364. .content {
  365. display: flex!important;
  366. flex-direction: column;
  367. overflow: hidden;
  368. .content-page{
  369. padding:20px 20px 0 20px!important;
  370. flex:1;
  371. display: flex!important;
  372. flex-direction: column;
  373. overflow: hidden;
  374. .pagination-container{
  375. height:50px;
  376. }
  377. }
  378. .el-row{
  379. margin-bottom:20px;
  380. }
  381. .button-box{
  382. display: flex;
  383. p:nth-child(1){
  384. margin-right:20px;
  385. }
  386. }
  387. }
  388. </style>