addRenwu.vue 12 KB

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