publish.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  1. <template>
  2. <div class="page">
  3. <div class="top adfac">
  4. <img src="@/assets/images/agent/arrow_left.png" @click="handleBack">
  5. <div class="spans">
  6. <span>问卷调研</span>
  7. <span>&nbsp;/&nbsp;问卷列表</span>
  8. <span class="last">&nbsp;/&nbsp;发布问卷</span>
  9. </div>
  10. </div>
  11. <div class="content">
  12. <div class="c_top adfacjb">
  13. <span>{{ title }}</span>
  14. <el-button type="primary" @click="reviewWj">预览问卷</el-button>
  15. </div>
  16. <div class="c_set">
  17. <div class="cs_title" style="margin-top: 0;">选择项目成员</div>
  18. <div class="cs_users adf">
  19. <div class="cu_l adfacjb">
  20. <img src="@/assets/images/agent/users_mini.png">
  21. <div class="cul_add" @click="handleAddUser">+ 添加</div>
  22. </div>
  23. <div class="cu_r adfac">
  24. <div class="cr_item adfacjb" v-for="(item,index) in params.persons" :key="index">
  25. <span>{{ item.name }}</span>
  26. <img src="@/assets/images/agent/remove_mini.png" @click="handleRemoveUser(item,index)">
  27. </div>
  28. </div>
  29. </div>
  30. <div class="cs_title">问卷回答设置</div>
  31. <div class="cs_zd adfac">
  32. <span>只允许作答</span>
  33. <el-input-number v-model="params.answerSetting" :min="1" controls-position="right" style="margin: 0 9px;"></el-input-number>
  34. <span>次</span>
  35. </div>
  36. <div class="cs_title">问卷作答时间设置</div>
  37. <div class="cs_time">
  38. <div class="ct_pre adfac">
  39. <span>开始时间</span>
  40. <el-date-picker v-model="params.startTime" type="datetime" placeholder="选择开始时间" style="width:311px;" @change="e=>handleChangeDatetime(e,'startTime')"></el-date-picker>
  41. </div>
  42. <div class="ct_pre adfac">
  43. <span>截止时间</span>
  44. <el-date-picker v-model="params.endTime" type="datetime" placeholder="选择截止时间" style="width:311px;" @change="e=>handleChangeDatetime(e,'endTime')"></el-date-picker>
  45. </div>
  46. </div>
  47. <div class="cs_btn adfac">
  48. <el-button :loading="!canSubmit" type="primary" @click="handleConfirm">确认</el-button>
  49. <el-button type="default" @click="handleBack">取消</el-button>
  50. </div>
  51. </div>
  52. </div>
  53. <el-dialog width="790px" :visible.sync="userShow" title="选择成员" @close="userShow=false">
  54. <div class="ed_coach adf">
  55. <div class="ec_l">
  56. <el-input placeholder="请输入成员名搜索" suffix-icon="el-icon-search" v-model="userName" style="width: 100%;"></el-input>
  57. <template v-if="!checkShow">
  58. <div class="ecl_gs">
  59. <div class="eg_title">按项目选</div>
  60. <div class="egt_item adfacjb" v-for="(item,index) in companyList" :key="index">
  61. <div class="ei_l adffc" style="cursor: pointer;">
  62. <div class="adfac">
  63. <span @click="handleChooseUser(item)">{{ item.programName }}</span>
  64. <span></span>
  65. </div>
  66. <div><span style="margin-left: 0;">{{ item.enterpriseName }}-{{ item.teamName }}</span></div>
  67. </div>
  68. <div class="ei_r" @click="handleChooseUser(item)">
  69. <span>成员</span>
  70. </div>
  71. </div>
  72. </div>
  73. </template>
  74. <template v-else>
  75. <div class="ecl_company">
  76. <i class="el-icon-arrow-left" @click="handleUserBack"></i>
  77. {{ companyName }}
  78. </div>
  79. <el-checkbox :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange" style="margin-top: 33px;">全选</el-checkbox>
  80. <div class="ecl_cbs">
  81. <el-checkbox v-model="user.checked" v-for="(user,index) in userList" :key="index" @change="handleChangeUser" style="margin-top: 24px;display: block;">{{ user.name }}</el-checkbox>
  82. </div>
  83. </template>
  84. </div>
  85. <div class="ec_r">
  86. <div class="ecr_text">已选择({{ selectedUsers.length }}/<span>{{ userList.length }}</span>)</div>
  87. <div class="ecr_names">
  88. <div class="en_pre adfacjc" v-for="(item,index) in selectedUsers" :key="index">
  89. <span>{{ item.name }}</span>
  90. <img src="@/assets/images/agent/delete_mini.png" @click="handleDeleteUser(item,index)">
  91. </div>
  92. </div>
  93. </div>
  94. </div>
  95. <div class="demo-drawer__footer" style="display: flex;justify-content: end;margin-top: 20px;">
  96. <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 认</el-button>
  97. <el-button @click="cancel" style="margin-right: 5%;">取 消</el-button>
  98. </div>
  99. </el-dialog>
  100. </div>
  101. </template>
  102. <script setup name="">
  103. import { ref, getCurrentInstance,onMounted } from 'vue'
  104. const { proxy } = getCurrentInstance();
  105. import { getProgramList,getCoachList,sendQuestionnaire } from '@/api/agent/index.js'
  106. const questionnaireId = ref('')
  107. const title = ref('')
  108. const type = ref('')
  109. const params = ref({
  110. questionnaireId:'',
  111. programId:'',
  112. teamId:'',
  113. userIds:[],
  114. persons:[],
  115. memberInfos:[],
  116. answerSetting:1,
  117. startTime:'',
  118. endTime:''
  119. })
  120. const typecfg = {
  121. 1: '初级',
  122. 2: '中级',
  123. 3: '高级'
  124. }
  125. const userShow = ref(false)
  126. const checkShow = ref(false)
  127. const companyName = ref('')
  128. const userName = ref('')
  129. const companyList = ref([])
  130. const userList = ref([])
  131. const selectedUsers = ref([])
  132. const checkAll = ref(false)
  133. const isIndeterminate = ref(false)
  134. const buttonLoading = ref(false)
  135. const canSubmit = ref(true)
  136. const handleAddUser = () => {
  137. userShow.value = true
  138. getProgramList({page:1,limit:-1}).then(res=>{
  139. if(res.code !==0) return proxy.$message({type:'warning',message:res.msg});
  140. companyList.value = res.data.list.map(l=>{
  141. return {
  142. id:l.id,
  143. programName:l.programName,
  144. enterpriseName:l.enterpriseName,
  145. teamName:l.teamName,
  146. teamId:l.teamId
  147. }
  148. });
  149. })
  150. }
  151. const handleBack = () => {
  152. proxy.$router.go(-1)
  153. }
  154. const handleRemoveUser = (item,index) => {
  155. params.value.persons.splice(index,1);
  156. params.value.userIds = params.value.persons.map(l=>l.id);
  157. }
  158. const handleConfirm = () => {
  159. if(!canSubmit.value) return
  160. canSubmit.value = false;
  161. if(params.value.userIds.length === 0){
  162. proxy.$message({type:'warning',message:'请选择项目成员'});
  163. canSubmit.value = true;
  164. return;
  165. }
  166. if(!params.value.startTime || !params.value.endTime){
  167. proxy.$message({type:'warning',message:'请设置问卷作答时间'});
  168. canSubmit.value = true;
  169. return;
  170. }
  171. params.value.memberInfos = params.value.persons.map(l=>{
  172. return {
  173. userId:l.id,
  174. realName:l.name
  175. }
  176. })
  177. let { persons ,userIds ,...paras } = params.value;
  178. let data = {...paras};
  179. sendQuestionnaire(data).then(res=>{
  180. if(res.code!==0){
  181. canSubmit.value = true;
  182. return proxy.$message({type:'warning',message:res.msg});
  183. }
  184. proxy.$message({type:'success',message:'问卷已发布!'});
  185. setTimeout(()=>{proxy.$router.go(-1)},1500)
  186. canSubmit.value = true;
  187. })
  188. }
  189. const handleChooseUser = (item) => {
  190. params.value.programId = item.id;
  191. params.value.teamId = item.teamId;
  192. getCoachList({teamId:item.teamId,page:1,limit:-1}).then(res=>{
  193. if(res.code!==0) return proxy.$message({type:'warning',message:res.msg});
  194. userList.value = res.data.list.map(l=>{
  195. return {id:l.id,name:l.realName,checked:false}
  196. })
  197. })
  198. checkShow.value = true
  199. companyName.value = item.programName
  200. }
  201. const handleUserBack = () => {
  202. checkShow.value = false
  203. companyName.value = ''
  204. }
  205. const handleChangeDatetime = (e,key) => {
  206. params.value[key] = proxy.parseTime(new Date(e), '{yy}-{mm}-{dd} {hh}:{ii}:{ss}');
  207. }
  208. const submitForm = () => {
  209. if(selectedUsers.value.length===0) return proxy.$message.warning('请至少选择一位成员')
  210. params.value.persons = JSON.parse(JSON.stringify(selectedUsers.value));
  211. params.value.userIds = params.value.persons.map(l=>l.id);
  212. checkAll.value = false;
  213. isIndeterminate.value = false;
  214. selectedUsers.value = [];
  215. userList.value = [];
  216. checkShow.value = false;
  217. userShow.value = false;
  218. }
  219. const cancel = () => {
  220. userShow.value = false;
  221. }
  222. const handleCheckAllChange = (val) => {
  223. selectedUsers.value = val ? JSON.parse(JSON.stringify(userList.value)) : [];
  224. isIndeterminate.value = false;
  225. userList.value.forEach(item => item.checked = val)
  226. }
  227. const handleChangeUser = () => {
  228. let trues = userList.value.filter(item => item.checked).length;
  229. if(trues>0&&trues<userList.value.length) isIndeterminate.value = true;
  230. else isIndeterminate.value = false;
  231. if(trues===userList.value.length) checkAll.value = true;
  232. else checkAll.value = false;
  233. selectedUsers.value = userList.value.filter(item => item.checked);
  234. }
  235. const handleDeleteUser = (item,index) => {
  236. let i = userList.value.findIndex(c => c.id === item.id);
  237. if(i>-1) userList.value[i].checked = false;
  238. selectedUsers.value.splice(index,1);
  239. let trues = userList.value.filter(item => item.checked).length;
  240. if(trues>0&&trues<userList.value.length) isIndeterminate.value = true;
  241. else isIndeterminate.value = false;
  242. if(trues===userList.value.length) checkAll.value = true;
  243. else checkAll.value = false;
  244. }
  245. const reviewWj = () => {
  246. proxy.$router.push({path:'/agentQuestionnaireDetail',query:{id:questionnaireId.value,title:title.value,type:typecfg[type.value]}});
  247. }
  248. onMounted(()=>{
  249. questionnaireId.value = proxy.$route.query.id;
  250. params.value.questionnaireId = proxy.$route.query.id;
  251. title.value = proxy.$route.query.title;
  252. type.value = proxy.$route.query.type;
  253. })
  254. </script>
  255. <style scoped lang="scss">
  256. .page{
  257. background: #FAFAFA;
  258. .top{
  259. width: 100%;
  260. height: 64px;
  261. background: #FFFFFF;
  262. border-bottom: 1px solid #F3F4F6;
  263. img{
  264. width: 36px;
  265. height: 36px;
  266. margin-left: 16px;
  267. cursor: pointer;
  268. }
  269. .spans{
  270. display: flex;
  271. align-items: center;
  272. margin-left: 23px;
  273. span{
  274. font-family: PingFangSC, PingFang SC;
  275. font-weight: 400;
  276. font-size: 14px;
  277. color: #6B7280;
  278. line-height: 14px;
  279. &.last{
  280. color: #111111;
  281. }
  282. }
  283. }
  284. }
  285. .content{
  286. width: calc(100% - 720px);
  287. height: calc(100vh - 88px);
  288. margin: 12px 360px;
  289. overflow-y: auto;
  290. .c_top{
  291. width: 100%;
  292. padding: 12px 20px;
  293. box-sizing: border-box;
  294. background: #FFFFFF;
  295. border-radius: 6px;
  296. span{
  297. font-family: PingFang-SC, PingFang-SC;
  298. font-weight: bold;
  299. font-size: 14px;
  300. color: #252525;
  301. line-height: 16px;
  302. }
  303. }
  304. .c_set{
  305. width: 100%;
  306. height: calc(100vh - 152px);
  307. background: #FFFFFF;
  308. border-radius: 6px;
  309. margin-top: 8px;
  310. padding: 28px 21px;
  311. box-sizing: border-box;
  312. .cs_title{
  313. font-family: PingFang-SC, PingFang-SC;
  314. font-weight: bold;
  315. font-size: 14px;
  316. color: #252525;
  317. line-height: 20px;
  318. margin-top: 30px;
  319. }
  320. .cs_users{
  321. width: 100%;
  322. height: 36px;
  323. border-radius: 6px;
  324. border: 1px solid #E5E7EB;
  325. margin-top: 20px;
  326. padding: 7px 12px;
  327. box-sizing: border-box;
  328. .cu_l{
  329. width: 104px;
  330. padding-right: 15px;
  331. box-sizing: border-box;
  332. &>img{
  333. width: 18px;
  334. height: 18px;
  335. margin-top: -5px;
  336. }
  337. .cul_add{
  338. width: 54px;
  339. height: 24px;
  340. border-radius: 4px;
  341. border: 1px solid #761E6A;
  342. font-family: PingFangSC, PingFang SC;
  343. font-weight: 400;
  344. font-size: 12px;
  345. color: #761E6A;
  346. line-height: 22px;
  347. text-align: center;
  348. margin-top: -2px;
  349. cursor: pointer;
  350. }
  351. }
  352. .cu_r{
  353. width: calc(100% - 104px);
  354. margin-left: -16px;
  355. .cr_item{
  356. padding: 4px 10px;
  357. background: #F9FAFB;
  358. border-radius: 6px;
  359. margin-left: 16px;
  360. span{
  361. font-family: PingFangSC, PingFang SC;
  362. font-weight: 400;
  363. font-size: 14px;
  364. color: #252525;
  365. line-height: 14px;
  366. }
  367. img{
  368. width: 16px;
  369. height: 16px;
  370. margin-left: 10px;
  371. cursor: pointer;
  372. }
  373. }
  374. }
  375. }
  376. .cs_zd{
  377. margin-top: 12px;
  378. span{
  379. font-family: PingFangSC, PingFang SC;
  380. font-weight: 400;
  381. font-size: 14px;
  382. color: #6B7280;
  383. line-height: 20px;
  384. }
  385. }
  386. .cs_time{
  387. margin-top: 6px;
  388. .ct_pre{
  389. margin-top: 30px;
  390. span{
  391. font-family: PingFangSC, PingFang SC;
  392. font-weight: 400;
  393. font-size: 14px;
  394. color: #6B7280;
  395. line-height: 20px;
  396. margin-right: 23px;
  397. }
  398. }
  399. }
  400. .cs_btn{
  401. margin-top: 70px;
  402. padding-left: 79px;
  403. }
  404. }
  405. }
  406. .ed_coach{
  407. margin-top: -20px;
  408. .ec_l{
  409. width: calc(50% - 1px);
  410. height: 100%;
  411. padding-right: 30px;
  412. box-sizing: border-box;
  413. border-right: 1px solid #ECEEF5;
  414. .ecl_gs{
  415. margin-top: 19px;
  416. .eg_title{
  417. font-family: PingFangSC, PingFang SC;
  418. font-weight: 400;
  419. font-size: 14px;
  420. color: #6B7280;
  421. line-height: 20px;
  422. }
  423. .egt_item{
  424. margin-top: 24px;
  425. .ei_l{
  426. span{
  427. font-family: PingFang-SC, PingFang-SC;
  428. font-weight: bold;
  429. font-size: 14px;
  430. color: #252525;
  431. line-height: 20px;
  432. &:last-child{
  433. font-weight: 400;
  434. color: #6B7280;
  435. margin-left: 20px;
  436. }
  437. }
  438. }
  439. .ei_r{
  440. span{
  441. font-family: PingFangSC, PingFang SC;
  442. font-weight: 400;
  443. font-size: 14px;
  444. color: #761E6A;
  445. line-height: 20px;
  446. position: relative;
  447. padding-left: 8px;
  448. cursor: pointer;
  449. &::before{
  450. content: '';
  451. width: 1px;
  452. height: 16px;
  453. background: #DDE0E6;
  454. position: absolute;
  455. left: 0;
  456. top: 50%;
  457. margin-top: -8px;
  458. }
  459. }
  460. }
  461. }
  462. }
  463. .ecl_company{
  464. margin-top: 19px;
  465. position: relative;
  466. font-family: PingFang-SC, PingFang-SC;
  467. font-weight: bold;
  468. font-size: 14px;
  469. color: #252525;
  470. line-height: 20px;
  471. text-align: center;
  472. i{
  473. position: absolute;
  474. left: 0;
  475. font-size: 14px;
  476. color: #252525;
  477. cursor: pointer;
  478. }
  479. }
  480. .ecl_cbs{
  481. width: 100%;
  482. // height: calc(100% - 143px);
  483. max-height: 376px;
  484. overflow-y: auto;
  485. }
  486. }
  487. .ec_r{
  488. width: 50%;
  489. padding-left: 30px;
  490. box-sizing: border-box;
  491. .ecr_text{
  492. font-family: PingFang-SC, PingFang-SC;
  493. font-weight: bold;
  494. font-size: 16px;
  495. color: #252525;
  496. line-height: 22px;
  497. span{
  498. color: #B9B9B9;
  499. }
  500. }
  501. .ecr_names{
  502. margin-left: -16px;
  503. overflow: hidden;
  504. .en_pre{
  505. float: left;
  506. padding: 10px;
  507. background: #F9FAFB;
  508. border-radius: 6px;
  509. margin: 19px 0 0 16px;
  510. span{
  511. font-family: PingFangSC, PingFang SC;
  512. font-weight: 400;
  513. font-size: 14px;
  514. color: #252525;
  515. line-height: 14px;
  516. }
  517. img{
  518. width: 16px;
  519. height: 16px;
  520. margin-left: 10px;
  521. cursor: pointer;
  522. }
  523. }
  524. }
  525. }
  526. }
  527. }
  528. </style>