index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  1. <template>
  2. <div class="app-container addContent" @click="clickPicker(1)">
  3. <div class="top-title-box">
  4. <p>信息发布</p>
  5. <p class="inquire-button-one" @click="submitForm">发布</p>
  6. </div>
  7. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  8. <el-form-item label="发送对象:" prop="messClass" class="form-tiem-box-two">
  9. <el-radio-group v-model="form.messClass">
  10. <el-radio style="width:100px;" :label='1'>人员</el-radio>
  11. <el-radio style="width:100px;" :label='3'>实验室</el-radio>
  12. </el-radio-group>
  13. </el-form-item>
  14. <el-form-item label="发送范围:" prop="picker" class="form-tiem-box" v-if="form.messClass == 1">
  15. <div class="picker-form-item">
  16. <!--<div class="border-box" @click.stop="clickPicker(2)">{{pickerNameLeft}}{{pickerNameLeft!=''&&pickerNameRight!=''?'/':''}}{{pickerNameRight}}</div>-->
  17. <div class="border-box" @click.stop="clickPicker(2)">{{pickerNameLeft==''&&pickerNameRight==''?'请选择':(pickerNameLeft!=''&&pickerNameRight!=''?pickerNameLeft+'/'+pickerNameRight:pickerNameLeft+pickerNameRight)}}</div>
  18. <div class="list-box">
  19. <p v-for="(item,index) in userList" :key="index">{{item.nickName}}</p>
  20. </div>
  21. <div class="position-box" v-if="positionType">
  22. <div class="position-top-box">
  23. <div class="position-left-box scrollbar-box">
  24. <p v-for="(item,index) in listDepartmentsList"
  25. :class="leftPositionType == item.deptId?'colorP':''"
  26. :key="index" @click.stop="positionClick(1,item)">{{item.deptName}}</p>
  27. </div>
  28. <div class="position-right-box scrollbar-box">
  29. <p v-for="(item,index) in optionselectList"
  30. :class="rightPositionType == item.postId?'colorP':''"
  31. :key="index" @click.stop="positionClick(2,item)">{{item.postName}}</p>
  32. </div>
  33. </div>
  34. <div class="position-bottom-box" @click="userClick(3)">人员列表 》</div>
  35. </div>
  36. </div>
  37. </el-form-item>
  38. <el-form-item label="发送范围:" prop="picker" class="form-tiem-box" v-if="form.messClass == 3">
  39. <div class="picker-form-item">
  40. <div class="border-box" @click.stop="subjectTypeClick(4)">{{subsData[0]?'已选择':'请选择'}}</div>
  41. <div class="list-box">
  42. <p v-for="(item,index) in subsData" :key="index">{{item.name}}</p>
  43. </div>
  44. </div>
  45. </el-form-item>
  46. <el-form-item label="过期日期:" prop="expirationDate" class="form-tiem-box" v-if="form.messClass == 3">
  47. <el-date-picker
  48. style="width:300px;"
  49. v-model="form.expirationDate"
  50. value-format="yyyy-MM-dd"
  51. type="date"
  52. placeholder="选择过期时间">
  53. </el-date-picker>
  54. </el-form-item>
  55. <el-form-item label="内容:" prop="content" class="form-tiem-box">
  56. <el-input
  57. style="width:600px;"
  58. type="textarea"
  59. :rows="6"
  60. maxlength="200"
  61. placeholder="请输入内容"
  62. v-model="form.content">
  63. </el-input>
  64. </el-form-item>
  65. </el-form>
  66. <subject-list ref="subjectOpen"></subject-list>
  67. <user-list ref="userOpen"></user-list>
  68. </div>
  69. </template>
  70. <script>
  71. import { addContent } from "@/api/laboratory/content";
  72. import userList from "./userList.vue"
  73. import subjectList from "./subjectList.vue"
  74. import { optionselect } from "@/api/laboratory/gradeManage";
  75. import { getDeptNoAuthList } from "@/api/system/dept";
  76. export default {
  77. name: "addContent",
  78. components: {
  79. subjectList,
  80. userList
  81. },
  82. data() {
  83. return{
  84. //下啦展示状态
  85. positionType:false,
  86. leftPositionType:"",
  87. listDepartmentsList:[],
  88. rightPositionType:"",
  89. optionselectList:[],
  90. pickerNameLeft:"",
  91. pickerNameRight:"",
  92. form:{
  93. messClass:1,
  94. deptIds:"",
  95. postIds:"",
  96. userIds:"",
  97. subIds:"",
  98. expirationDate:"",
  99. content:"",
  100. picker:"",//判断是否为空
  101. },
  102. //选中实验室
  103. subsData:[],
  104. //选中用户
  105. userList:[],
  106. // 表单校验
  107. rules: {
  108. messClass:[
  109. {required: true, message: '请选择发送对象', trigger: 'change'}
  110. ],
  111. picker:[
  112. {required: true, message: '请选择发送范围', trigger: 'change'}
  113. ],
  114. expirationDate:[
  115. {required: true, message: '请选择过期时间', trigger: 'change'}
  116. ],
  117. content:[
  118. {required: true, message: '请输入内容', trigger: 'change'},
  119. { required: true, message: "请输入内容", validator: this.spaceJudgment, trigger: "blur" }
  120. ],
  121. },
  122. }
  123. },
  124. created() {
  125. },
  126. mounted(){
  127. this.optionselect();
  128. this.getDeptNoAuthList();
  129. },
  130. methods: {
  131. //选择实验室
  132. subjectTypeClick(){
  133. if(this.subsData[0]){
  134. this.$refs.subjectOpen.show(this.subsData);
  135. }else{
  136. this.$refs.subjectOpen.show();
  137. }
  138. },
  139. //接收实验室列表数据
  140. takeSubjectData(ids,data){
  141. this.$set(this.form,'subIds',ids);
  142. this.$set(this,'subsData',data);
  143. this.$refs.subjectOpen.show();
  144. if(this.subsData[0]){
  145. this.form.picker = 1;
  146. }else{
  147. this.form.picker = "";
  148. }
  149. },
  150. //选择人员
  151. userClick(){
  152. if(this.userList){
  153. this.$refs.userOpen.show(this.userList);
  154. }else{
  155. this.$refs.userOpen.show();
  156. }
  157. },
  158. //接收人员列表数据
  159. takeUserData(ids,data){
  160. console.log("人员数据",ids);
  161. this.$set(this.form,'userIds',ids);
  162. this.$set(this,'userList',data);
  163. this.$refs.userOpen.show();
  164. if(this.userList[0]){
  165. this.form.picker = 1;
  166. this.pickerNameLeft = "已选择";
  167. this.pickerNameRight = "";
  168. }else{
  169. this.form.picker = "";
  170. this.pickerNameLeft = "";
  171. this.pickerNameRight = "";
  172. }
  173. this.leftPositionType = "";
  174. this.rightPositionType = "";
  175. },
  176. //选择人员分类
  177. positionClick(type,item){
  178. console.log("type",type)
  179. console.log("item",item)
  180. if(type == 1){
  181. this.leftPositionType = item.deptId;
  182. this.pickerNameLeft = item.deptName
  183. this.userList = [];
  184. }else if(type == 2){
  185. this.rightPositionType = item.postId;
  186. this.pickerNameRight = item.postName
  187. this.userList = [];
  188. }
  189. if(this.leftPositionType && this.rightPositionType){
  190. this.form.picker = 1;
  191. }else{
  192. this.form.picker = "";
  193. }
  194. },
  195. //获取职位列表
  196. optionselect(){
  197. optionselect({status:0}).then(response => {
  198. let list = response.data;
  199. let obj = {
  200. postName:"全部职位",
  201. postId:"allMax"
  202. };
  203. list.unshift(obj)
  204. this.optionselectList = list;
  205. });
  206. },
  207. getDeptNoAuthList(){
  208. getDeptNoAuthList().then(response => {
  209. let list = response.data;
  210. let obj = {
  211. deptName:"全部学院",
  212. deptId:"allMax"
  213. };
  214. list.unshift(obj)
  215. this.listDepartmentsList = list;
  216. });
  217. },
  218. clickPicker(type){
  219. console.log("type触发")
  220. if(type == 1){
  221. this.positionType = false;
  222. }else if(type == 2){
  223. this.positionType = true;
  224. }else if(type == 3){
  225. //人员列表选择
  226. }else if(type == 4){
  227. //实验室列表选择
  228. }
  229. },
  230. /** 提交按钮 */
  231. submitForm() {
  232. let self = this;
  233. this.$refs["form"].validate(valid => {
  234. if (valid) {
  235. let obj ={
  236. messClass:self.form.messClass,
  237. content:self.form.content,
  238. };
  239. console.log('obj123')
  240. if(self.form.messClass == 1){
  241. if(self.userList[0]){
  242. obj.userIds = self.form.userIds.join()
  243. }else{
  244. if(self.leftPositionType == 'allMax'){
  245. let list = [];
  246. for(let i=0;i<self.listDepartmentsList.length;i++){
  247. if(self.listDepartmentsList[i].deptId != 'allMax'){
  248. list.push(self.listDepartmentsList[i].deptId);
  249. }
  250. }
  251. obj.deptIds = list.join();
  252. }else{
  253. obj.deptIds = self.leftPositionType;
  254. }
  255. if(self.rightPositionType == 'allMax'){
  256. let list = [];
  257. for(let i=0;i<self.optionselectList.length;i++){
  258. if(self.optionselectList[i].postId != 'allMax'){
  259. list.push(self.optionselectList[i].postId);
  260. }
  261. }
  262. obj.postIds = list.join();
  263. }else{
  264. obj.postIds = self.rightPositionType;
  265. }
  266. }
  267. }else if(this.form.messClass == 3){
  268. obj.expirationDate = self.form.expirationDate;
  269. obj.subIds = self.form.subIds.join()
  270. }
  271. console.log('obj',obj);
  272. addContent(obj).then(response => {
  273. self.msgSuccess("新增成功");
  274. self.form = {
  275. messClass:1,
  276. deptIds:"",
  277. postIds:"",
  278. userIds:"",
  279. subIds:"",
  280. expirationDate:"",
  281. content:"",
  282. picker:"",//判断是否为空
  283. };
  284. self.subsData = "";
  285. self.userList = "";
  286. self.subsData = "";
  287. self.leftPositionType = "";
  288. self.rightPositionType = "";
  289. self.pickerNameLeft = "";
  290. self.pickerNameRight = "";
  291. self.resetForm("form");
  292. self.$forceUpdate();
  293. });
  294. }
  295. });
  296. },
  297. },
  298. }
  299. </script>
  300. <style scoped lang="scss">
  301. .addContent {
  302. display: flex!important;
  303. flex-direction: column;
  304. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  305. padding:0 20px 20px!important;
  306. *{
  307. margin:0;
  308. }
  309. .top-title-box{
  310. display: flex;
  311. p:nth-child(1){
  312. flex:1;
  313. line-height:80px;
  314. color:#0045AF;
  315. font-size:18px;
  316. }
  317. p:nth-child(2){
  318. margin:20px 20px 0 0;
  319. }
  320. p:nth-child(3){
  321. margin-top:20px;
  322. }
  323. }
  324. .form-tiem-box{
  325. min-height:70px;
  326. }
  327. .form-tiem-box-two{
  328. height:60px;
  329. }
  330. .picker-form-item{
  331. display: flex;
  332. position: relative;
  333. .border-box{
  334. width:300px;
  335. height:40px;
  336. line-height:40px;
  337. border:1px solid #dedede;
  338. border-radius:4px;
  339. cursor: pointer;
  340. font-size:14px;
  341. padding:0 10px;
  342. color:#999;
  343. }
  344. .list-box{
  345. p{
  346. display: inline-block;
  347. overflow: hidden;
  348. margin:0 0 10px 10px;
  349. padding:0 20px;
  350. background: rgba(204,230,254,1);
  351. color:#0183FA;
  352. border-radius:6px;
  353. text-align: center;
  354. font-size:14px;
  355. line-height:40px;
  356. }
  357. }
  358. .position-box{
  359. position: absolute;
  360. border:1px solid #dedede;
  361. background: #fff;
  362. border-bottom-left-radius:10px;
  363. border-bottom-right-radius:10px;
  364. top:38px;
  365. left:0;
  366. width:300px;
  367. height:200px;
  368. z-index:1;
  369. display: flex;
  370. flex-direction: column;
  371. font-weight:500;
  372. .position-top-box{
  373. flex:1;
  374. display: flex;
  375. overflow-y: hidden;
  376. .position-left-box{
  377. border-right:1px solid #dedede;
  378. flex:1;
  379. p{
  380. height:30px;
  381. line-height:30px;
  382. font-size:14px;
  383. padding:0 10px;
  384. cursor: pointer;
  385. display:block;
  386. overflow:hidden;
  387. text-overflow:ellipsis;
  388. white-space:nowrap;
  389. }
  390. p:hover{
  391. background: rgba(204,230,254,1);
  392. color:#0183FA;
  393. }
  394. .colorP{
  395. background: rgba(204,230,254,1);
  396. color:#0183FA;
  397. }
  398. }
  399. .position-right-box{
  400. flex:1;
  401. p{
  402. height:30px;
  403. line-height:30px;
  404. font-size:14px;
  405. padding:0 10px;
  406. cursor: pointer;
  407. display:block;
  408. overflow:hidden;
  409. text-overflow:ellipsis;
  410. white-space:nowrap;
  411. }
  412. p:hover{
  413. background: rgba(204,230,254,1);
  414. color:#0183FA;
  415. }
  416. .colorP{
  417. background: rgba(204,230,254,1);
  418. color:#0183FA;
  419. }
  420. }
  421. }
  422. .position-bottom-box{
  423. height:30px;
  424. line-height:30px;
  425. border-top:1px solid #dedede;
  426. font-size:14px;
  427. text-align: center;
  428. color:#333333;
  429. cursor: pointer;
  430. }
  431. }
  432. }
  433. }
  434. </style>