addProject.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. <template>
  2. <view class="content">
  3. <view class="param">
  4. <view class="all-text">创建项目需求</view>
  5. <view class="proName">项目标题</view>
  6. <input class="proINname" v-model="pName" placeholder="请输入项目标题"/>
  7. <view class="proMiao">项目描述</view>
  8. <textarea class="proINname proIMi" v-model="projectContent" placeholder="请选择项目描述"/>
  9. <view class="proMiao">附件</view>
  10. <view class="upload-img">
  11. <uni-file-picker limit="3"
  12. @select='selectUpload'
  13. @delete="deleteHandle"
  14. :auto-upload='false'
  15. file-extname='pdf,docx,jpg,png,jpeg'
  16. file-mediatype="all"
  17. @success='uploadSuccess'
  18. @fail='uploadFail'
  19. :list-styles='listStyles'
  20. v-model='fileList'
  21. ></uni-file-picker>
  22. </view>
  23. <span style="margin: 20rpx 0 0 20rpx;">支持pdf/word/xlsx格式,单个文件大小不超过5MB</span>
  24. <view class="proMiao">主办单位/主办人</view>
  25. <uni-data-picker placeholder="请选择主办单位" popup-title="请选择主办人" :localdata="range" v-model="value"
  26. @change="onchange" @nodeclick="onnodeclick" @popupopened="onpopupopened" @popupclosed="onpopupclosed">
  27. </uni-data-picker>
  28. <!-- <uni-data-select class="proINname"
  29. v-model="value" placeholder="请选择主办单位"
  30. :localdata="range"
  31. @change="change1"
  32. ></uni-data-select>
  33. <view class="proMiao">主办人</view>
  34. <uni-data-select class="proINname"
  35. v-model="peopleValue" placeholder="请选择主办人"
  36. :localdata="rangePeople"
  37. @change="change"
  38. ></uni-data-select> -->
  39. <view class="proMiao">协办单位/协办人</view>
  40. <uni-data-picker placeholder="请选择协办单位" popup-title="请选择协办人" :showSearch= "true" :localdata="range" v-model="value2"
  41. @change="onchange2" @nodeclick="onnodeclick2" @popupopened="onpopupopened2" @popupclosed="onpopupclosed2">
  42. </uni-data-picker>
  43. <view class="proINname" style="height: 100%;">
  44. <view class="tag-view" v-for="(value,key) in userListSelect" :key="key" @click="clearTagAdmin(value)">
  45. <uni-tag :text="value.parent_value.organize+'/'+value.text" type="primary" ></uni-tag>
  46. <!-- {{value.parent_value.organize}}/{{value.text}} -->
  47. <uni-icons class="clearBtn" type="clear" size="15" color="#ccc" />
  48. </view>
  49. </view>
  50. <!-- <mySelectCheckbox class="proINname" placeholder="请选择协办单位" v-model="value2" multiple dataKey="label" dataValue="value" :localdata="data"
  51. @change="changeXie"></mySelectCheckbox>
  52. <view class="proMiao">协办人</view>
  53. <mySelectCheckbox class="proINname" placeholder="请选择协办人" v-model="peopleValue2" multiple dataKey="label" dataValue="value" :localdata="dataPeople"
  54. @change="changeXiePeo"></mySelectCheckbox> -->
  55. <view class="proMiao">项目级别</view>
  56. <uni-data-select class="proINname"
  57. v-model="jibieValue" placeholder="请选择项目级别"
  58. :localdata="jibie"
  59. @change="change"
  60. ></uni-data-select>
  61. <!-- <view class="proMiao">关联流程</view>
  62. <uni-data-select class="proINname"
  63. v-model="value" placeholder="请选择关联流程"
  64. :localdata="range"
  65. @change="change"
  66. ></uni-data-select> -->
  67. <view class="proMiao">项目来源</view>
  68. <uni-data-select class="proINname"
  69. v-model="fromValue" placeholder="请选择项目来源"
  70. :localdata="from"
  71. @change="change"
  72. ></uni-data-select>
  73. <!-- <view class="proMiao jindu">完成进度</view>
  74. <view class="weidu">维度权重40%</view>
  75. <view class="addRen" @click="addRen">新增任务</view> -->
  76. <!-- 任务列表 -->
  77. <!-- <view style="width: 100%;margin: 50rpx 0 0 20rpx;">
  78. <view class="renwu" v-for="(item,index) in renwu" :key="index" @click="clickRenwu">
  79. <view>{{item.name}}</view>
  80. <view>{{item.time}}</view>
  81. <view style="display: flex;">
  82. <view class="renwu-bu bianji">编辑</view>
  83. <view class="renwu-bu delete">删除</view>
  84. </view>
  85. </view>
  86. </view> -->
  87. <view class="proMiao">项目评分人</view>
  88. <mySelectCheckbox class="proINname" placeholder="请选择项目评分人" v-model="peoplescore" multiple dataKey="label" dataValue="value" :localdata="scorePeople"
  89. @change="changeScore"></mySelectCheckbox>
  90. <view class="project">
  91. <view class="butt quxiao" @click="quxiao">取消</view>
  92. <view class="butt queren" @click="addProject">确认创建</view>
  93. </view>
  94. <view style="width: 100%;height: 60rpx;"></view>
  95. </view>
  96. </view>
  97. </template>
  98. <script>
  99. import configdata from '@/common/config.js'
  100. import mySelectCheckbox from '../../components/my-selectCheckbox.vue'
  101. export default {
  102. components:{mySelectCheckbox},
  103. data() {
  104. return {
  105. pName:'',//项目标题
  106. projectContent:'',//项目描述
  107. //主办单位
  108. value: '',
  109. range: [],
  110. userListSelect1:[],
  111. //主办人
  112. peopleValue:'',
  113. rangePeople:[],
  114. //协办
  115. userListSelect:[],
  116. value2:'',
  117. data: [],
  118. xieban:[],//协办传入值数组
  119. xieValue:[],//协办传入id
  120. //协办人
  121. peopleValue2:[],
  122. dataPeople: [],
  123. xiebanPeople:[],//协办传入值数组
  124. xieValuePeople:[],//协办传入id
  125. //评分人
  126. peoplescore:[],
  127. scorePeople: [],
  128. scorePeople22:[],//协办传入值数组
  129. scoreValuePeople:[],//协办传入id
  130. // 项目级别
  131. jibieValue:0,
  132. jibie:[
  133. { value: 0, text: "正常" },
  134. { value: 1, text: "紧急" },
  135. ],
  136. // 项目来源
  137. fromValue:0,
  138. from:[
  139. { value: 0, text: "涉内" },
  140. { value: 1, text: "涉外" },
  141. ],
  142. fileList: [],
  143. fileList2: [],
  144. fileList22:'',
  145. listStyles: {
  146. "borderStyle": {
  147. "width": "0", // 边框宽度
  148. },
  149. "border": false, // 是否显示边框
  150. "dividline": false
  151. },
  152. renwu:[
  153. {name:'xxx任务',time:'2024-04-11'},
  154. {name:'xxx任务',time:'2024-04-11'},
  155. {name:'xxx任务',time:'2024-04-11'},
  156. ],
  157. }
  158. },
  159. onShow() {
  160. // this.getDanwei()
  161. this.getPeopleZhu()
  162. },
  163. methods: {
  164. // 主办单位
  165. change1(e) {
  166. console.log("e:", e);
  167. // this.getPeopleZhu(e)
  168. },
  169. onnodeclick(data) {
  170. console.log(data);
  171. this.userListSelect1 = data
  172. // this.getPeople()
  173. },
  174. onpopupopened(e) {
  175. console.log('popupopened');
  176. },
  177. onpopupclosed(e) {
  178. console.log('popupclosed');
  179. },
  180. onchange(e) {
  181. console.log('---------onchange:', e);
  182. var acc=e.detail.value[0].text
  183. this.getPeople(acc)
  184. },
  185. //协办单位选择
  186. changeXie(e){
  187. this.xieban=[]
  188. this.xieValue=[]
  189. console.log('e:', e);
  190. e.map(item =>{
  191. this.xieban.push(item.label)
  192. this.xieValue.push(item.value)
  193. })
  194. },
  195. clearTagAdmin(value){
  196. this.userListSelect = this.userListSelect.filter(item => item != value);
  197. },
  198. onnodeclick2(data) {
  199. console.log(data);
  200. if(data.parent_value){//存在父级
  201. let dataId = data.value;
  202. this.userListSelect.push(data);
  203. this.userListSelect = [...new Set(this.userListSelect)]//es6数组去重
  204. }
  205. console.log('多选',this.userListSelect)
  206. },
  207. onpopupopened2(e) {
  208. console.log('popupopened');
  209. },
  210. onpopupclosed2(e) {
  211. console.log('popupclosed');
  212. },
  213. onchange2(e) {
  214. console.log('---------onchange:', e);
  215. },
  216. //协办人选择
  217. changeXiePeo(e){
  218. this.xieban=[]
  219. this.xieValue=[]
  220. console.log('e:', e);
  221. e.map(item =>{
  222. this.xieban.push(item.label)
  223. this.xieValue.push(item.value)
  224. })
  225. },
  226. //评分人选择
  227. changeScore(e){
  228. this.scorePeople22=[]
  229. this.scoreValuePeople=[]
  230. console.log('e:', e);
  231. e.map(item =>{
  232. this.scorePeople22.push(item.label)
  233. this.scoreValuePeople.push(item.value)
  234. })
  235. },
  236. //获取单位
  237. getDanwei(){
  238. this.range=[]
  239. this.data=[]
  240. uni.showLoading({
  241. title: '加载中',
  242. mask: true, // 是否显示透明蒙层,防止触摸穿透
  243. });
  244. this.$Request.postT('/api/Organize/query').then(res => {
  245. if (res.code==200&&res.data) {
  246. // this.range =res.data.map(item =>{
  247. // return {
  248. // value: item.id,
  249. // text: item.oname,
  250. // }
  251. // })
  252. this.data =res.data.map(item =>{
  253. return {
  254. value: item.id,
  255. label: item.oname,
  256. }
  257. })
  258. console.log(this.range)
  259. }
  260. uni.hideLoading();
  261. });
  262. },
  263. //获取主办协办人,评分人
  264. getPeopleZhu(){
  265. this.range=[]
  266. this.rangePeople=[]
  267. uni.showLoading({
  268. title: '加载中',
  269. mask: true, // 是否显示透明蒙层,防止触摸穿透
  270. });
  271. this.$Request.postJson('/api/sysProject/queryCoUsers',{}).then(res => {
  272. if (res.code==200) {
  273. var lianji=[]
  274. for(var i=0;i<res.data.length;i++){
  275. if(res.data[i].userList.length>0){
  276. lianji.push(res.data[i])
  277. }
  278. }
  279. this.range =lianji.map(item =>{
  280. return {
  281. value: item,
  282. text: item.organize,
  283. children:item.userList.map(item =>{
  284. return{
  285. value: item.id,
  286. text: item.userName,
  287. }
  288. })
  289. }
  290. })
  291. console.log(this.range,'人')
  292. }else{
  293. var ii=JSON.stringify(res)
  294. console.log(res,res.data)
  295. console.log(JSON.parse(res))
  296. console.log(JSON.parse(ii))
  297. }
  298. uni.hideLoading();
  299. });
  300. },
  301. //根据单位获取人员(评分人)
  302. getPeople(acc){
  303. console.log(this.userListSelect1)
  304. this.scorePeople=[]
  305. uni.showLoading({
  306. title: '加载中',
  307. mask: true, // 是否显示透明蒙层,防止触摸穿透
  308. });
  309. this.$Request.postT('/api/sysUser/queryScorer',{
  310. organizes:acc
  311. }).then(res => {
  312. if (res.code==200) {
  313. console.log(res,'评分')
  314. this.scorePeople =res.data.map(item =>{
  315. return {
  316. value: item.id,
  317. label: item.userName,
  318. }
  319. })
  320. console.log(this.scorePeople,'人')
  321. }else{
  322. var ii=JSON.stringify(res)
  323. console.log(res,res.data)
  324. console.log(JSON.parse(res))
  325. console.log(JSON.parse(ii))
  326. }
  327. uni.hideLoading();
  328. });
  329. },
  330. //取消
  331. quxiao(){
  332. uni.switchTab({
  333. url:'/pages/project/index'
  334. })
  335. },
  336. //新增项目
  337. addProject(){
  338. console.log('协办',this.userListSelect1.parent_value.organize,this.value2,this.userListSelect)
  339. console.log('评分人',this.scoreValuePeople)
  340. console.log(this.jibie[this.jibieValue].text)
  341. var xieban=[]
  342. var xiebanValue=[]
  343. this.userListSelect.map(item =>{
  344. xieban.push(item.parent_value.organize)
  345. xiebanValue.push(item.value)
  346. })
  347. console.log(xieban,xiebanValue)
  348. let that = this
  349. if (!that.pName) {
  350. that.$queue.showToast("请输入项目标题");
  351. }else if (!that.projectContent) {
  352. that.$queue.showToast("请输入项目描述");
  353. } else if (!that.value) {
  354. that.$queue.showToast("请选择主办单位");
  355. } else if (!that.value2) {
  356. that.$queue.showToast("请选择协办单位");
  357. }else {
  358. uni.showLoading({
  359. title: '加载中',
  360. mask: true, // 是否显示透明蒙层,防止触摸穿透
  361. });
  362. var data={
  363. "projectName": that.pName, // 项目名称
  364. "projectFrom": that.from[that.fromValue].text, // 项目来源
  365. "projectLevel": that.jibie[that.jibieValue].text, // 项目等级
  366. "projectContent": that.projectContent, // 项目描述
  367. "fileUrl": that.fileList22, // 附件
  368. "organize": that.userListSelect1.parent_value.organize, // 主办单位-单选
  369. "sposoner": that.value, // 主办人ID-单选
  370. "coOrganize": xieban.join(","), // 协办单位-多选
  371. "coSposoner": xiebanValue.join(","), // 协办人ID-多选
  372. "scorer": that.scoreValuePeople.join(",") // 评分人ID-多选
  373. }
  374. that.$Request.postJson('/api/sysProject/add',data).then(res => {
  375. if (res.code==200) {
  376. uni.showToast({
  377. title: '添加成功',
  378. icon: 'none',
  379. duration:800
  380. });
  381. uni.hideLoading()
  382. setTimeout(function() {
  383. uni.switchTab({
  384. url:'/pages/project/index'
  385. })
  386. }, 1000)
  387. } else {
  388. uni.hideLoading();
  389. uni.showToast({
  390. title: res.message,
  391. icon: 'none',
  392. duration:800
  393. });
  394. }
  395. });
  396. }
  397. },
  398. //新增任务
  399. addRen(){
  400. uni.navigateTo({
  401. url:'/pages/project/addRenwu'
  402. })
  403. },
  404. //任务详情
  405. clickRenwu(){
  406. uni.navigateTo({
  407. url:'/pages/project/renwuX'
  408. })
  409. },
  410. // 上传附件
  411. uploadSuccess(e) {
  412. console.log('上传成功', e)
  413. },
  414. uploadFail(e) {
  415. console.log('上传失败:', e)
  416. },
  417. //删除文件
  418. deleteHandle(index){
  419. console.log(index)
  420. this.fileList2.splice(index.index,1)
  421. // console.log(this.fileList2)
  422. this.fileList22=this.fileList2.join(",")
  423. },
  424. async selectUpload(e) {
  425. console.log('上传:', e)
  426.  let data = new FormData();
  427.   data.set("file", e.tempFiles[0].file);
  428.   let res = await this.$axios({
  429.     method: "post",
  430.     url: this.config('APIHOST1') + "/api/sysFile/upload",
  431.     headers: {
  432. tokenW: localStorage.getItem("token"),
  433. "Content-Type": "multipart/form-data"
  434.     },
  435.     data: data,
  436.   });
  437. // return res
  438.   console.log(res, "图片上传成功");
  439.   if (res.data.code == 200) {
  440. console.log(this.fileList)
  441.     this.fileList2.push(res.data.data);
  442. this.fileList22=this.fileList2.join(",")
  443. // console.log(this.fileList2.join(","))
  444.   } else if(res.message=="登录凭证已过去,请重新登录"){
  445. uni.removeStorageSync("tokenW")
  446. uni.removeStorageSync("roleId")
  447. uni.showModal({
  448. title: '提示',
  449. content: '用户信息失效,请重新登录!',
  450. showCancel: false, // 是否显示取消按钮,默认为 true // 是否显示取消按钮,默认为 true
  451. success: function(res) {
  452. if (res.confirm) {
  453. }
  454. }
  455. });
  456. }else {
  457.     uni.showToast({
  458. title: res.message,
  459. icon: 'none',
  460. duration:800
  461. });
  462.   }
  463. },
  464. config: function (name) {
  465. var info = null
  466. if (name) {
  467. var name2 = name.split('.') //字符分割
  468. if (name2.length > 1) {
  469. info = configdata[name2[0]][name2[1]] || null
  470. } else {
  471. info = configdata[name] || null
  472. }
  473. if (info == null) {
  474. let web_config = cache.get('web_config')
  475. if (web_config) {
  476. if (name2.length > 1) {
  477. info = web_config[name2[0]][name2[1]] || null
  478. } else {
  479. info = web_config[name] || null
  480. }
  481. }
  482. }
  483. }
  484. return info
  485. },
  486. }
  487. }
  488. </script>
  489. <style>
  490. .content {
  491. display: flex;
  492. flex-direction: column;
  493. align-items: center;
  494. justify-content: center;
  495. }
  496. .param{
  497. margin: 20rpx 0 0 0;
  498. width: 100%;
  499. background-color: rgba(255, 255, 255, 1);
  500. font-size: 28rpx;
  501. font-weight: 400;
  502. line-height: 41rpx;
  503. color: rgba(0, 0, 0, 1);
  504. }
  505. .all-text{
  506. margin: 22rpx 0 0 20rpx;
  507. font-size: 32rpx;
  508. font-weight: 500;
  509. color: rgba(0, 0, 0, 1);
  510. }
  511. .proName{
  512. margin: 23rpx 0 0 20rpx;
  513. }
  514. .proINname{
  515. margin: 25rpx 0 0 21rpx;
  516. width: 709rpx;
  517. height: 90rpx;
  518. border-radius: 13rpx;
  519. background: rgba(245, 248, 252, 1);
  520. border: 1rpx solid rgba(229, 229, 229, 1);
  521. font-size: 28rpx;
  522. line-height: 90rpx;
  523. /* color: rgba(179, 179, 179, 1); */
  524. }
  525. .proIMi{
  526. height: 315rpx;
  527. }
  528. .proMiao{
  529. margin: 31rpx 0 0 20rpx;
  530. }
  531. /* 上传附件 */
  532. .upload-img{
  533. /* margin: 25rpx 0 0 21rpx;
  534. width: 200rpx;
  535. opacity: 1;
  536. border-radius: 13rpx;
  537. background: rgba(0, 97, 255, 0.1);
  538. border: 1rpx solid rgba(0, 97, 255, 1); */
  539. }
  540. .jindu{
  541. font-size: 32rpx;
  542. font-weight: 500;
  543. line-height: 46rpx;
  544. }
  545. .weidu{
  546. margin: 7rpx 0 0 20rpx;
  547. font-size: 24rpx;
  548. line-height: 35rpx;
  549. color: rgba(128, 128, 128, 1);
  550. }
  551. .addRen{
  552. margin: -80rpx 0 0 581rpx;
  553. width: 149rpx;
  554. height: 59rpx;
  555. border-radius: 92rpx;
  556. background: rgba(0, 97, 255, 1);
  557. font-size: 28rpx;
  558. line-height: 59rpx;
  559. color: rgba(255, 255, 255, 1);
  560. text-align: center;
  561. }
  562. /* 任务列表 */
  563. .renwu{
  564. display: flex;
  565. margin-top: 6rpx;
  566. width: 709rpx;
  567. height: 90rpx;
  568. border-radius: 13rpx;
  569. background: rgba(245, 248, 252, 1);
  570. border: 1rpx solid rgba(229, 229, 229, 1);
  571. font-size: 28rpx;
  572. justify-content: space-evenly;
  573. align-items: center;
  574. }
  575. .renwu-bu{
  576. width: 105rpx;
  577. height: 50rpx;
  578. border-radius: 110rpx;
  579. line-height:50rpx;
  580. text-align: center;
  581. }
  582. .bianji{
  583. border: 1rpx solid rgba(0, 97, 255, 1);
  584. color: rgba(0, 97, 255, 1);
  585. }
  586. .delete{
  587. margin-left: 20rpx;
  588. border: 1rpx solid rgba(212, 48, 48, 1);
  589. color: rgba(212, 48, 48, 1);
  590. }
  591. .project{
  592. display: flex;
  593. margin: 61rpx 0 0 0;
  594. justify-content: space-evenly;
  595. }
  596. .butt{
  597. width: 330rpx;
  598. height: 90rpx;
  599. border-radius: 117rpx;
  600. font-size: 32rpx;
  601. line-height: 90rpx;
  602. text-align: center;
  603. }
  604. .quxiao{
  605. border: 1rpx solid rgba(0, 97, 255, 1);
  606. color: rgba(0, 97, 255, 1);
  607. }
  608. .queren{
  609. background: rgba(0, 97, 255, 1);
  610. color: rgba(255, 255, 255, 1);
  611. }
  612. </style>