华西海圻ELN前端工程
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

346 lines
10 KiB

  1. <template>
  2. <div class="study-subject">
  3. <div class="subject-top">{{study.name}}</div>
  4. <div class="subject-study">
  5. <div class="study-info">{{$t('page.business.study.study.sn')}}<span>{{study.sn}}</span></div>
  6. <div class="study-info">{{$t('page.business.study.study.name')}}<span>{{study.name}}</span></div>
  7. <div class="study-info">{{$t('page.business.study.study.createDate')}}<span>{{study.createTime}}</span></div>
  8. </div>
  9. <div class="subject-operate">
  10. <div class="operate-img"></div>
  11. <div class="operate-left">{{$t('page.business.study.studyEnter.syxkxx')}}</div>
  12. <div class="operate-right">
  13. <i class="el-icon-edit operate-icon" @click="editSubject" v-if="operate && (study.leader==userId || checkRole(['TFM']))"></i>
  14. </div>
  15. </div>
  16. <div class="subject-content">
  17. <div class="subject-item" :class="selectedSubjectId===item.id?'active':''" v-for="(item,index) in subjectList" :key="index" @click="changeSelectedSubject(item)">
  18. <div class="subject-item-name">{{item.deptName}}({{item.leaderName}})</div>
  19. <div class="subject-item-add" v-if="operate && item.leader==userId">
  20. <el-button type="primary" plain @click.stop="yq(item)">{{$t('page.business.study.studyEnter.yq')}}</el-button>
  21. </div>
  22. </div>
  23. </div>
  24. <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" :title="infoDialog.title" :visible.sync="infoDialog.visible" width="800px" append-to-body>
  25. <el-table v-loading="infoDialog.loading" :data="infoDialog.list">
  26. <el-table-column label="" type="index" width="50">
  27. <template slot-scope="scope">
  28. <el-checkbox v-model="scope.row.select"></el-checkbox>
  29. </template>
  30. </el-table-column>
  31. <el-table-column :label="$t('page.business.study.studyEnter.xk')" prop="deptName" align="center" />
  32. <el-table-column :label="$t('page.business.study.studyEnter.czfzr')" align="center">
  33. <template slot-scope="scope">
  34. <div class="subject-table-box">
  35. <div class="subject-table-left">
  36. <el-input v-model="scope.row.leaderName" maxlength="100" readonly />
  37. </div>
  38. <div class="subject-table-right">
  39. <el-button type="primary" plain @click="chooseLeader(scope.row)">{{$t('page.business.study.studyEnter.xzfzr')}}</el-button>
  40. </div>
  41. </div>
  42. </template>
  43. </el-table-column>
  44. </el-table>
  45. <div slot="footer" class="dialog-footer">
  46. <el-button type="primary" @click="save">{{$t('form.saveConfirm')}}</el-button>
  47. <el-button @click="infoDialog.visible = false">{{$t('form.cancel')}}</el-button>
  48. </div>
  49. </el-dialog>
  50. <SelectDeptUserDialog ref="selectSubjectDeptUserDialog" @change="changeSubject" />
  51. <SelectDeptUserMultipleDialog ref="selectSubjectDeptUserMultipleDialog" @change="changeMember" />
  52. <Sign ref="subjectSignRef" @callback="doSign" />
  53. </div>
  54. </template>
  55. <script>
  56. import { checkPermi, checkRole } from "@/utils/permission";
  57. import {
  58. studySubject_listByStudyId,
  59. studySubject_getAllListByStudyId,
  60. studySubject_save
  61. } from '@/api/business/study/studySubject'
  62. import {
  63. studySubjectUser_getListByStudySubjectId,
  64. studySubjectUser_save
  65. } from '@/api/business/study/studySubjectUser'
  66. import SelectDeptUserDialog from '@/views/business/comps/select/SelectDeptUserDialog.vue';
  67. import SelectDeptUserMultipleDialog from '@/views/business/comps/select/SelectDeptUserMultipleDialog.vue';
  68. import Sign from './sign.vue'
  69. export default {
  70. name: 'StudySubject',
  71. props: {
  72. study:{
  73. type:Object,
  74. default:()=>{
  75. return {}
  76. },
  77. deep: true,
  78. },
  79. operate:{
  80. type:Boolean,
  81. default:false
  82. }
  83. },
  84. watch: {
  85. study: {
  86. immediate: true,
  87. handler(v) {
  88. this.getList()
  89. }
  90. },
  91. },
  92. components: {SelectDeptUserDialog,SelectDeptUserMultipleDialog,Sign},
  93. filters: {},
  94. data() {
  95. return {
  96. userId:this.$store.getters.id,
  97. subjectList:[],
  98. selectedSubjectId:'',
  99. infoDialog:{
  100. title:this.$t('page.business.study.studyEnter.xzxk'),
  101. visible:false,
  102. loading:false,
  103. list:[],
  104. subject:{
  105. leader:'',
  106. leaderName:'',
  107. },
  108. saveList:[]
  109. },
  110. memberSubject:{},
  111. signType:'',
  112. memberList:[]
  113. }
  114. },
  115. created() {},
  116. methods: {
  117. checkPermi,
  118. checkRole,
  119. getList(){
  120. if(this.study.id){
  121. this.selectedSubjectId = ''
  122. studySubject_listByStudyId({studyId:this.study.id}).then(response => {
  123. this.subjectList = response.data;
  124. for(let i=0;i<this.subjectList.length;i++){
  125. let item = this.subjectList[i]
  126. if(item.leader==this.userId || (item.userIdList && item.userIdList.length>0 && item.userIdList.indexOf(this.userId)>-1)){
  127. this.selectedSubjectId = item.id
  128. break
  129. }
  130. }
  131. if(this.selectedSubjectId === ''){
  132. this.selectedSubjectId = this.subjectList.length>0?this.subjectList[0].id:''
  133. }
  134. this.$emit('change',this.selectedSubjectId)
  135. })
  136. }
  137. },
  138. changeSelectedSubject(item){
  139. this.selectedSubjectId = item.id
  140. this.$emit('change',this.selectedSubjectId)
  141. },
  142. editSubject(){
  143. this.infoDialog.list = []
  144. this.infoDialog.loading = true
  145. studySubject_getAllListByStudyId({studyId:this.study.id}).then(response => {
  146. this.infoDialog.list = response.data;
  147. this.infoDialog.visible = true;
  148. }).finally(()=>{
  149. this.infoDialog.loading = false;
  150. });
  151. },
  152. save(){
  153. let postList = _.filter(this.infoDialog.list, (o)=> { return o.select })
  154. if(postList.length>0){
  155. for(let i=0;i<postList.length;i++){
  156. let item = postList[i]
  157. if(!item.leader || !item.leaderName){
  158. this.$message.error(`${item.deptName}还没设置负责人`)
  159. return false
  160. }
  161. }
  162. }
  163. this.infoDialog.saveList = postList
  164. this.signType = 'save'
  165. this.$refs.subjectSignRef.show(this.$t('page.business.study.study.rybg'),this.$t('page.business.study.study.rybg'))
  166. },
  167. doSign(val){
  168. if(this.signType==='save'){
  169. this.doSave(val)
  170. }
  171. if(this.signType==='member'){
  172. this.doChangeMember(val)
  173. }
  174. },
  175. doSave(sign){
  176. this.$modal.loading()
  177. studySubject_save({
  178. studyId:this.study.id,
  179. subjectList:this.infoDialog.saveList,
  180. sign:sign
  181. }).then(() => {
  182. this.infoDialog.visible = false
  183. this.$refs.subjectSignRef.cancel()
  184. this.getList()
  185. }).finally(() => {
  186. this.$modal.closeLoading()
  187. })
  188. },
  189. chooseLeader(row){
  190. this.infoDialog.subject = row
  191. this.$refs.selectSubjectDeptUserDialog.show(this.infoDialog.subject.leader,this.infoDialog.subject.leaderName)
  192. },
  193. changeSubject(val){
  194. this.infoDialog.subject.leader = val.id
  195. this.infoDialog.subject.leaderName = val.name
  196. this.infoDialog.subject.select = true
  197. let index = _.findIndex(this.infoDialog.list,(item)=>{
  198. return item.deptId===this.infoDialog.subject.deptId
  199. })
  200. if(index>-1){
  201. this.infoDialog.list.splice(index,1,this.infoDialog.subject)
  202. }
  203. },
  204. yq(item){
  205. this.memberSubject = item
  206. studySubjectUser_getListByStudySubjectId({studySubjectId:item.id}).then(response => {
  207. let memberList = []
  208. for(let i=0;i<response.data.length;i++){
  209. memberList.push({
  210. id:response.data[i].userId,
  211. name:response.data[i].userName,
  212. })
  213. }
  214. this.$refs.selectSubjectDeptUserMultipleDialog.show(memberList)
  215. }).finally(()=>{
  216. });
  217. },
  218. changeMember(val){
  219. let postList = []
  220. if(val.length>0){
  221. for(let i=0;i<val.length;i++){
  222. let item = val[i]
  223. postList.push({
  224. userId:item.id,
  225. userName:item.name,
  226. })
  227. }
  228. }
  229. this.memberList = postList
  230. this.signType = 'member'
  231. this.$refs.subjectSignRef.show(this.$t('page.business.study.study.rybg'),this.$t('page.business.study.study.rybg'))
  232. },
  233. doChangeMember(sign){
  234. this.$modal.loading()
  235. studySubjectUser_save({
  236. studySubjectId:this.memberSubject.id,
  237. subjectUserList:this.memberList,
  238. sign:sign
  239. }).then(() => {
  240. this.$refs.subjectSignRef.cancel()
  241. }).finally(() => {
  242. this.$modal.closeLoading()
  243. })
  244. },
  245. }
  246. }
  247. </script>
  248. <style lang="scss" scoped>
  249. .study-subject {
  250. .subject-top {
  251. background: #f0f7ff;
  252. border-top-left-radius: 3px;
  253. border-top-right-radius: 3px;
  254. border-top: 3px solid #409eff;
  255. padding: 20px 0;
  256. text-align: center;
  257. color: #409eff;
  258. font-weight: bold;
  259. }
  260. .subject-study{
  261. background: #fafcff;
  262. padding: 20px;
  263. color: #666666;
  264. position: relative;
  265. .study-info{
  266. margin-bottom: 20px;
  267. span{
  268. color: #777;
  269. }
  270. &:last-child{
  271. margin-bottom: 0;
  272. }
  273. }
  274. }
  275. .subject-operate{
  276. margin: 20px 0;
  277. display: flex;
  278. flex-direction: row;
  279. align-items: center;
  280. .operate-img{
  281. flex-shrink: 0;
  282. height: 15px;
  283. background: #3178ff;
  284. width: 3px;
  285. }
  286. .operate-left{
  287. flex-shrink: 0;
  288. font-weight: bold;
  289. padding-left: 10px;
  290. }
  291. .operate-right{
  292. flex-grow: 1;
  293. text-align: right;
  294. .operate-icon{
  295. cursor: pointer;
  296. }
  297. }
  298. }
  299. .subject-content{
  300. .subject-item{
  301. margin-bottom: 10px;
  302. padding: 10px;
  303. display: flex;
  304. flex-direction: row;
  305. align-items: center;
  306. justify-content: space-between;
  307. background: #f9fafc;
  308. border-radius: 5px;
  309. cursor: pointer;
  310. &.active{
  311. border: 1px solid #47a1ff;
  312. }
  313. .subject-item-name{
  314. color: #777;
  315. }
  316. .subject-item-add{
  317. }
  318. }
  319. }
  320. }
  321. .subject-table-box{
  322. display: flex;
  323. flex-direction: row;
  324. align-items: center;
  325. .subject-table-left{
  326. flex-shrink: 0;
  327. width: 60%;
  328. }
  329. .subject-table-right{
  330. flex-grow: 1;
  331. margin-left: 5px;
  332. }
  333. }
  334. </style>