addRenwu.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. <template>
  2. <view class="content">
  3. <view class="param">
  4. <view class="proMiao">任务名称</view>
  5. <input class="proINname" v-model="renwuName" placeholder="请输入任务名称"/>
  6. <view class="proMiao">评分标准</view>
  7. <textarea class="proINname proIMi" v-model="scoreStandard" placeholder="请输入评分标准"/>
  8. <view class="proMiao">附件</view>
  9. <view class="upload-img">
  10. <uni-file-picker limit="3"
  11. @select='selectUpload'
  12. @delete="deleteHandle"
  13. :auto-upload='false'
  14. file-extname='pdf,docx,jpg,png,jpeg'
  15. file-mediatype="all"
  16. @success='uploadSuccess'
  17. @fail='uploadFail'
  18. :list-styles='listStyles'
  19. v-model='fileList'
  20. ></uni-file-picker>
  21. </view>
  22. <span style="margin: 20rpx 0 0 20rpx;">支持pdf/word/xlsx格式,单个文件大小不超过5MB</span>
  23. <view class="proMiao">评分上限</view>
  24. <input class="proINname" placeholder="请输入评分上限" type="number" v-model="scoreLimit"/>
  25. <view class="proMiao">权重</view>
  26. <input class="proINname" placeholder="请输入权重" type="digit" v-model="weight"/>
  27. <view class="proMiao">任务负责人</view>
  28. <view @click="toggle()">
  29. <view class="proINname" v-if="peopleValue==''">请选择任务负责人</view>
  30. <view class="proINname" v-else>{{peopleValue}}</view>
  31. <!-- <input class="proINname" v-model="peopleValue" placeholder="请选择任务负责人"/> -->
  32. <!-- <uni-data-select class="proINname" :disabled="true"
  33. v-model="peopleValue" placeholder="请选择主办人"
  34. :localdata="rangePeople"
  35. ></uni-data-select> -->
  36. </view>
  37. <view class="proMiao">提醒时间</view>
  38. <uni-datetime-picker class="proINname" type="datetime" v-model="remindTime" @change="changeLog" />
  39. <view class="proMiao">预警时间</view>
  40. <uni-datetime-picker class="proINname" type="datetime" v-model="warnTime" @change="changeLog" />
  41. <view class="proMiao">任务周期</view>
  42. <uni-datetime-picker class="proINname" v-model="datetimerange" type="datetimerange" rangeSeparator="至" />
  43. <!-- 操作键 -->
  44. <view class="project">
  45. <view class="butt quxiao" @click="quxiao">取消</view>
  46. <view class="butt queren" @click="addRenwu">确认创建</view>
  47. </view>
  48. <view style="width: 100%;height: 60rpx;"></view>
  49. <!-- 任务负责人弹出框-->
  50. <uni-popup ref="popup" background-color="#fff">
  51. <view class="popup-content">
  52. <view class="popup-title">
  53. <view @click="quPopup">取消</view>
  54. <view>选择任务负责人</view>
  55. <view style="color: rgba(0, 97, 255, 1);" @click="selectPeo">确定</view>
  56. </view>
  57. <scroll-view scroll-y="true" class="scroll_view_style">
  58. <view class="popup-list">
  59. <radio-group @change="radioChange" v-for="(item,index) in people" :key="index">
  60. <view class="l-line"></view>
  61. <view class="l-kuang">
  62. <view class="l-circle"></view>
  63. <view style="margin-left: 20rpx;width: 320px;">
  64. <view style="font-size: 28rpx;">{{item.userName}}</view>
  65. <view style="font-size: 24rpx;">{{item.department}}</view>
  66. </view>
  67. <label class="l-label">
  68. <view>
  69. <radio :id="item.userName" :value="item.userName" :checked="index==peopleCruuent"></radio>
  70. </view>
  71. </label>
  72. </view>
  73. </radio-group>
  74. </view>
  75. </scroll-view>
  76. </view>
  77. </uni-popup>
  78. </view>
  79. </view>
  80. </template>
  81. <script>
  82. import configdata from '@/common/config.js'
  83. export default {
  84. data() {
  85. return {
  86. renwuName:'',//任务名称
  87. projectId:'',//项目id
  88. scoreStandard:'',//评价标准
  89. scoreLimit:'',//评分上限
  90. weight:'',//权重
  91. remindTime: '',//提醒时间
  92. warnTime:'',//预警时间
  93. datetimerange: [],
  94. people:[],
  95. peopleCruuent:0,
  96. peopleValue:'',
  97. // 附件
  98. fileList: [],
  99. fileList2: [],
  100. fileList22:'',
  101. listStyles: {
  102. "borderStyle": {
  103. "width": "0", // 边框宽度
  104. },
  105. "border": false, // 是否显示边框
  106. "dividline": false
  107. },
  108. page:1,
  109. size:10,
  110. totalCount:0,
  111. }
  112. },
  113. onLoad(option) {
  114. this.projectId=option.proId
  115. this.people=JSON.parse(decodeURIComponent(option.people))
  116. },
  117. methods: {
  118. // 任务负责人弹框
  119. toggle() {
  120. console.log('dd')
  121. // open 方法传入参数 等同在 uni-popup 组件上绑定 type属性
  122. this.$refs.popup.open('bottom')
  123. // this.getPeople()
  124. },
  125. //取消弹框
  126. quPopup(){
  127. this.$refs.popup.close()
  128. },
  129. //确定负责人
  130. selectPeo(){
  131. this.$refs.popup.close()
  132. this.peopleValue=this.people[this.peopleCruuent].userName
  133. },
  134. // 选择负责人
  135. radioChange: function(evt) {
  136. console.log(evt)
  137. for (let i = 0; i < this.people.length; i++) {
  138. if (this.people[i].userName === evt.detail.value) {
  139. this.peopleCruuent = i;
  140. this.peopleValue=this.people[this.peopleCruuent].userName
  141. break;
  142. }
  143. }
  144. },
  145. //选择负责人
  146. getPeople(){
  147. this.people=[]
  148. uni.showLoading({
  149. title: '加载中',
  150. mask: true, // 是否显示透明蒙层,防止触摸穿透
  151. });
  152. this.$Request.postJson('/api/sysProject/queryCoUsers',{}).then(res => {
  153. if (res.code==200) {
  154. // var lianji=[]
  155. // for(var i=0;i<res.data.length;i++){
  156. // if(res.data[i].organize==acc){
  157. // lianji=res.data[i].userList
  158. // }
  159. // }
  160. // console.log(lianji,'评分')
  161. // this.scorePeople =lianji.map(item =>{
  162. // return {
  163. // value: item.id,
  164. // label: item.userName,
  165. // }
  166. // })
  167. if (this.page == 1) {
  168. console.log('哈')
  169. this.people = res.data.rows
  170. } else {
  171. this.people = this.people.concat(res.data.rows)
  172. }
  173. console.log(this.people,'人')
  174. }else{
  175. var ii=JSON.stringify(res)
  176. console.log(res,res.data)
  177. console.log(JSON.parse(res))
  178. console.log(JSON.parse(ii))
  179. }
  180. uni.hideLoading();
  181. });
  182. },
  183. //取消
  184. quxiao(){
  185. uni.redirectTo({
  186. url:'/pages/project/projectChange'
  187. })
  188. },
  189. //新增任务
  190. addRenwu(){
  191. let that = this
  192. if (!that.renwuName) {
  193. that.$queue.showToast("请输入任务名称");
  194. }else if (!that.scoreStandard) {
  195. that.$queue.showToast("请输入评分标准");
  196. }else if (!that.scoreLimit) {
  197. that.$queue.showToast("请输入评分上限");
  198. }else if (!that.weight) {
  199. that.$queue.showToast("请输入权重");
  200. }else if (!that.remindTime) {
  201. that.$queue.showToast("请选择提醒时间");
  202. }else if (!that.warnTime) {
  203. that.$queue.showToast("请选择预警时间");
  204. }else if (!that.datetimerange) {
  205. that.$queue.showToast("请选择周期");
  206. }else {
  207. uni.showLoading({
  208. title: '加载中',
  209. mask: true, // 是否显示透明蒙层,防止触摸穿透
  210. });
  211. var data={
  212. "taskName": that.renwuName, // 任务名称
  213. "projectId": that.projectId, // 项目ID
  214. "scoreStandard": that.scoreStandard, // 评价标准
  215. "fileUrl": that.fileList22, // 附件
  216. "scoreLimit": that.scoreLimit, // 评分上限
  217. "weight": that.weight, // 权重
  218. "remindTime": that.remindTime, // 提醒时间
  219. "warnTime": that.warnTime, // 预警时间
  220. "header": that.people[that.peopleCruuent].id, // 负责人
  221. "startTime": that.datetimerange[0], // 周期-起始时间
  222. "endTime": that.datetimerange[1] // 周期-结束时间
  223. }
  224. that.$Request.postJson('/api/sysTask/add',data).then(res => {
  225. if (res.code==200) {
  226. uni.showToast({
  227. title: '添加成功',
  228. icon: 'none',
  229. duration:800
  230. });
  231. uni.hideLoading()
  232. setTimeout(function() {
  233. uni.switchTab({
  234. url:'/pages/project/index'
  235. })
  236. }, 1000)
  237. } else {
  238. uni.hideLoading();
  239. uni.showToast({
  240. title: res.message,
  241. icon: 'none',
  242. duration:800
  243. });
  244. }
  245. });
  246. }
  247. },
  248. // 上传附件
  249. uploadSuccess(e) {
  250. console.log('上传成功', e)
  251. },
  252. uploadFail(e) {
  253. console.log('上传失败:', e)
  254. },
  255. //删除文件
  256. deleteHandle(index){
  257. console.log(index)
  258. this.fileList2.splice(index.index,1)
  259. // console.log(this.fileList2)
  260. this.fileList22=this.fileList2.join(",")
  261. },
  262. async selectUpload(e) {
  263. console.log('上传:', e)
  264.  let data = new FormData();
  265.   data.set("file", e.tempFiles[0].file);
  266.   let res = await this.$axios({
  267.     method: "post",
  268.     url: this.config('APIHOST1') + "/api/sysFile/upload",
  269.     headers: {
  270. tokenW: localStorage.getItem("token"),
  271. "Content-Type": "multipart/form-data"
  272.     },
  273.     data: data,
  274.   });
  275. // return res
  276.   console.log(res, "图片上传成功");
  277.   if (res.data.code == 200) {
  278. console.log(this.fileList)
  279.     this.fileList2.push(res.data.data);
  280. this.fileList22=this.fileList2.join(",")
  281. // console.log(this.fileList2.join(","))
  282.   } else if(res.message=="登录凭证已过去,请重新登录"){
  283. uni.removeStorageSync("tokenW")
  284. uni.removeStorageSync("roleId")
  285. uni.showModal({
  286. title: '提示',
  287. content: '用户信息失效,请重新登录!',
  288. showCancel: false, // 是否显示取消按钮,默认为 true // 是否显示取消按钮,默认为 true
  289. success: function(res) {
  290. if (res.confirm) {
  291. }
  292. }
  293. });
  294. }else {
  295.     uni.showToast({
  296. title: res.message,
  297. icon: 'none',
  298. duration:800
  299. });
  300.   }
  301. },
  302. config: function (name) {
  303. var info = null
  304. if (name) {
  305. var name2 = name.split('.') //字符分割
  306. if (name2.length > 1) {
  307. info = configdata[name2[0]][name2[1]] || null
  308. } else {
  309. info = configdata[name] || null
  310. }
  311. if (info == null) {
  312. let web_config = cache.get('web_config')
  313. if (web_config) {
  314. if (name2.length > 1) {
  315. info = web_config[name2[0]][name2[1]] || null
  316. } else {
  317. info = web_config[name] || null
  318. }
  319. }
  320. }
  321. }
  322. return info
  323. },
  324. }
  325. }
  326. </script>
  327. <style>
  328. .content {
  329. display: flex;
  330. flex-direction: column;
  331. align-items: center;
  332. justify-content: center;
  333. }
  334. .param{
  335. margin: 20rpx 0 0 0;
  336. width: 100%;
  337. background-color: rgba(255, 255, 255, 1);
  338. font-size: 28rpx;
  339. font-weight: 400;
  340. line-height: 41rpx;
  341. color: rgba(0, 0, 0, 1);
  342. }
  343. .proMiao{
  344. margin: 31rpx 0 0 20rpx;
  345. }
  346. /* 上传附件 */
  347. .upload-img{
  348. /* margin: 25rpx 0 0 21rpx;
  349. width: 200rpx;
  350. height: 80rpx;
  351. opacity: 1;
  352. border-radius: 13rpx;
  353. background: rgba(0, 97, 255, 0.1);
  354. border: 1rpx solid rgba(0, 97, 255, 1); */
  355. }
  356. .proINname{
  357. margin: 25rpx 0 0 21rpx;
  358. width: 709rpx;
  359. height: 90rpx;
  360. border-radius: 13rpx;
  361. background: rgba(245, 248, 252, 1);
  362. border: 1rpx solid rgba(229, 229, 229, 1);
  363. font-size: 28rpx;
  364. line-height: 90rpx;
  365. /* color: rgba(179, 179, 179, 1); */
  366. }
  367. .proIMi{
  368. height: 315rpx;
  369. }
  370. /* 操作键 */
  371. .project{
  372. display: flex;
  373. margin: 61rpx 0 0 0;
  374. justify-content: space-evenly;
  375. }
  376. .butt{
  377. width: 330rpx;
  378. height: 90rpx;
  379. border-radius: 117rpx;
  380. font-size: 32rpx;
  381. line-height: 90rpx;
  382. text-align: center;
  383. }
  384. .quxiao{
  385. border: 1rpx solid rgba(0, 97, 255, 1);
  386. color: rgba(0, 97, 255, 1);
  387. }
  388. .queren{
  389. background: rgba(0, 97, 255, 1);
  390. color: rgba(255, 255, 255, 1);
  391. }
  392. /* 任务负责人弹出框 */
  393. .popup-content{
  394. height: 452px;
  395. overflow-x: hidden;
  396. .scroll_view_style{
  397. height: 100%;
  398. }
  399. }
  400. .popup-title{
  401. display: flex;
  402. width: 100%;
  403. height: 104rpx;
  404. font-size: 32rpx;
  405. line-height: 104rpx;
  406. justify-content: space-around;
  407. color: rgba(0, 0, 0, 1);
  408. }
  409. .l-line{
  410. width: 100%;
  411. border: 1rpx solid rgba(230, 230, 230, 1);
  412. }
  413. .l-kuang{
  414. margin: 40rpx 0 0 20rpx;
  415. display: flex;
  416. }
  417. .l-circle{
  418. width: 80rpx;
  419. height: 80rpx;
  420. border-radius: 50%;
  421. background-color:rgba(204, 204, 204, 1);
  422. }
  423. .l-label1{
  424. width: 50rpx;
  425. height: 50rpx;
  426. opacity: 1;
  427. border-radius: 50%;
  428. background-color: rgba(0, 97, 255, 1);
  429. }
  430. .l-label{
  431. /* margin-left: 404rpx; */
  432. /* width: 50rpx;
  433. height: 50rpx;
  434. opacity: 1;
  435. border-radius: 50%;
  436. border: 1rpx solid rgba(166, 166, 166, 1); */
  437. }
  438. </style>