gradingControlAdd.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. <!-- 分级管控完成工作 -->
  2. <template>
  3. <view id="accessQualification">
  4. <scroll-view scroll-y @scrolltolower="scrollGet" class="info-max-box">
  5. <view class="list">
  6. <view class="list_li">
  7. <view class="list_li_t">
  8. <view class="list_li_t_l" :style="'color:'+labData.levelColor+';border-color:'+labData.levelColor">{{labData.levelName}}</view>
  9. <view class="list_li_t_c">{{labData.subName}}</view>
  10. <view class="list_li_t_r">{{labData.typeName}}</view>
  11. </view>
  12. <view class="list_li_b">
  13. <view class="list_li_b_t">
  14. <view class="list_li_b_t_t">
  15. <view class="list_li_b_t_t_n">
  16. <view class="list_li_b_t_t_l" :class="[control.ruleType== '日管控' ? 'purple': '', control.ruleType=='周管控'? 'blue': '',control.ruleType=='月管控'? 'orange': '',control.ruleType=='年管控'? 'green': '',]">{{control.ruleType}}</view>
  17. <view class="list_li_b_t_t_c">{{control.ruleName}}</view>
  18. <view class="list_li_b_t_t_r" v-if="control.isExpired==1">(过期未完成)</view>
  19. <view class="list_li_b_t_t_rr" >{{control.endDate}}</view>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="flex-view">
  24. <view><text style="margin-right: 20rpx;"></text>执行方式:</view>
  25. <view>{{control.isAll==1?'多人执行':'单人执行'}}</view>
  26. </view>
  27. <view class="flex-view">
  28. <view><text style="margin-right: 20rpx;"></text>规则描述:</view>
  29. <view>{{control.ruleRemark}}</view>
  30. </view>
  31. <view class="list_li_b_b2"><text style="position: relative;top: 4rpx;color: #f00;margin-right: 10rpx;">*</text>执行描述:</view>
  32. <textarea class="list_li_b_b3" v-model="param.detail.remark" maxlength="30" placeholder-class="placeholder-style" placeholder="请输入执行描述"></textarea>
  33. <view class="list_li_b_b4" v-if="control.isUpload==1"><text style="position: relative;top: 4rpx;color: #f00;margin-right: 10rpx;">*</text>执行材料:<label @click="itemUpData(item)">+ 请上传执行材料</label></view>
  34. <view class="list_li_b_b6" v-if="upList.length>0" v-for="(item,index) in upList" :key="index">
  35. <view @click="download(item)">{{item.name}}</view>
  36. <view @click="delImg(index)">
  37. <img src="@/images/icon_fjgk_sc.png">
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </scroll-view>
  44. <view class="bottom-button-box" @click="goSafeAccess">完成</view>
  45. </view>
  46. </template>
  47. <script>
  48. import { gradingControlAdd,readByLoginUser } from '@/api/index.js'
  49. import { config } from '@/api/request/config.js'
  50. export default {
  51. data() {
  52. return {
  53. labData:{},
  54. control:{},
  55. upList:[],
  56. param:{
  57. subId:'',//实验室id
  58. ruleId:'',//规则ID
  59. ruleUserId:'',//规则细则
  60. id:'',//记录id
  61. ruleType:'',
  62. endDate:'',
  63. detail:{
  64. imgName:'',//文件名
  65. imgUrl:'',//文件路径
  66. imgType:'',//文件类型
  67. remark:'',
  68. }
  69. },
  70. messageUserId:""
  71. }
  72. },
  73. onLoad(option) {
  74. if(option.item){
  75. let item = JSON.parse(decodeURIComponent(option.item));
  76. let item2 = JSON.parse(decodeURIComponent(option.item2));
  77. this.labData=item
  78. this.control=item2
  79. this.param.subId=item.subId;
  80. this.param.ruleId=item2.ruleId;
  81. this.param.ruleUserId=item2.ruleUserId;
  82. // this.param.id=item2.recordId;
  83. this.param.ruleType=item2.ruleType;
  84. this.param.endDate=item2.endDate;
  85. if(option.messageUserId){
  86. this.messageUserId = option.messageUserId;
  87. }
  88. }
  89. },
  90. onShow(){
  91. },
  92. methods: {
  93. download(item){
  94. if(item.type == 'png' || item.type == 'jpg' || item.type == 'jpeg' || item.type == 'gif'){
  95. //查看图片
  96. wx.previewImage({
  97. urls: [config.base_url+item.url], //需要预览的图片http链接列表,多张的时候,url直接写在后面就行了
  98. current: '', // 当前显示图片的http链接,默认是第一个
  99. success: function(res) {},
  100. fail: function(res) {},
  101. complete: function(res) {},
  102. })
  103. }else if(item.type == 'pdf' || item.type == 'doc' || item.type == 'docx'){
  104. uni.showLoading({
  105. title: '下载中'
  106. });
  107. //下载文档
  108. wx.downloadFile({
  109. url: config.base_url+item.url,
  110. header: {
  111. Authorization: uni.getStorageSync('token')
  112. },
  113. success: function (res) {
  114. console.log("resresresresresres",res)
  115. const fileManager = wx.getFileSystemManager()
  116. console.log('wx.env.USER_DATA_PATH',wx.env.USER_DATA_PATH);
  117. console.log('item.name',item.name);
  118. console.log('item.type',item.type);
  119. const filePath = wx.env.USER_DATA_PATH + '/' + item.name
  120. console.log('filePath',filePath);
  121. fileManager.saveFile({
  122. tempFilePath: res.tempFilePath,
  123. filePath,
  124. success: () => {
  125. uni.hideLoading();
  126. wx.openDocument({
  127. filePath: filePath,
  128. showMenu: true,
  129. fileType: item.type
  130. })
  131. },
  132. fail: function (res){
  133. uni.hideLoading();
  134. uni.showToast({
  135. title: '下载失败',
  136. icon:"none",
  137. mask:true,
  138. duration: 2000
  139. });
  140. }
  141. })
  142. },
  143. fail: function (res){
  144. uni.hideLoading();
  145. uni.showToast({
  146. title: '下载失败',
  147. icon:"none",
  148. mask:true,
  149. duration: 2000
  150. });
  151. }
  152. })
  153. }
  154. },
  155. delImg(index){
  156. let self = this;
  157. uni.showModal({
  158. title: '',
  159. cancelColor:'#999999',
  160. confirmColor:'#0183FA',
  161. content: '确定删除吗?',
  162. success (res) {
  163. if (res.confirm) {
  164. self.upList.splice(index,1)
  165. self.$forceUpdate();
  166. } else if (res.cancel) {
  167. }
  168. }
  169. })
  170. },
  171. //上传
  172. itemUpData(item){
  173. let self = this;
  174. if(this.upList.length>4){
  175. uni.showToast({
  176. title: '最多只能上传5个',
  177. icon:"none",
  178. mask:true,
  179. duration: 2000
  180. });
  181. return
  182. }
  183. uni.showActionSheet({
  184. itemList: ['上传文件', '上传图片'],
  185. success: function (res) {
  186. if(res.tapIndex == 0){
  187. //上传文件
  188. self.upData(item);
  189. }else if(res.tapIndex == 1){
  190. //上传图片
  191. self.upImg(item);
  192. }
  193. },
  194. fail: function (res) {
  195. console.log(res.errMsg);
  196. }
  197. });
  198. },
  199. upImg(item) {
  200. let self = this;
  201. wx.chooseImage({
  202. count: 1,
  203. sizeType: ["original", "compressed"],
  204. sourceType: ["album", "camera"],
  205. success: function(res) {
  206. console.log(res)
  207. let text = res.tempFilePaths[0].substring(res.tempFilePaths[0].lastIndexOf('.') + 1);
  208. if(text != 'png' && text != 'jpg' && text != 'jpeg' && text != 'gif' && text != 'pdf' && text != 'doc' && text != 'docx'){
  209. uni.showToast({
  210. title: '仅支持png/jpg/jpeg/gif/pdf/doc/docx类型的文件上传',
  211. icon:"none",
  212. mask:true,
  213. duration: 2000
  214. });
  215. return
  216. }
  217. let upObj = {
  218. name:'照片.'+text,
  219. path:res.tempFilePaths[0],
  220. type:text,
  221. }
  222. self.upDataFunction(item,upObj);
  223. // let tempFilePaths = res.tempFilePaths[0];
  224. // self.upDataFunction(tempFilePaths,upObj);
  225. }
  226. });
  227. },
  228. //上传文件
  229. upData(item){
  230. let self = this;
  231. wx.chooseMessageFile({
  232. count: 1,
  233. type: 'all',
  234. success (res) {
  235. console.log(11111)
  236. console.log(res)
  237. console.log(res.tempFiles)
  238. let text = res.tempFiles[0].path.substring(res.tempFiles[0].path.lastIndexOf('.') + 1);
  239. if(text != 'png' && text != 'jpg' && text != 'jpeg' && text!= 'gif' && text != 'pdf' && text != 'doc' && text != 'docx'){
  240. uni.showToast({
  241. title: '仅支持png/jpg/jpeg/gif/pdf/doc/docx类型的文件上传',
  242. icon:"none",
  243. mask:true,
  244. duration: 2000
  245. });
  246. return
  247. }
  248. let upObj = {
  249. name:res.tempFiles[0].name,
  250. path:res.tempFiles[0].path,
  251. type:text,
  252. }
  253. self.upDataFunction(item,upObj);
  254. }
  255. })
  256. },
  257. async upDataFunction(item,upObj){
  258. var self = this;
  259. uni.showLoading({
  260. title: '上传中',
  261. mask: true
  262. });
  263. uni.uploadFile({
  264. url: config.base_url+'/base/file/upload', //仅为示例,非真实的接口地址
  265. header:{'Authorization':uni.getStorageSync('token')},
  266. filePath: upObj.path,
  267. name: 'file',
  268. formData: {
  269. 'user': 'test'
  270. },
  271. success: (uploadFileRes) => {
  272. let res = JSON.parse(uploadFileRes.data);
  273. if(res.code == 200){
  274. let obj = {
  275. name:upObj.name,
  276. url:config.base_url+res.data.url,
  277. realUrl:res.data.url,
  278. type:upObj.type
  279. }
  280. this.upList.push(obj);
  281. this.$forceUpdate();
  282. console.log(this.upList)
  283. }else{
  284. uni.showToast({
  285. title: res.msg,
  286. icon:"none",
  287. mask:true,
  288. duration: 2000
  289. });
  290. }
  291. },
  292. fail: err => {},
  293. complete: () => {
  294. uni.hideLoading()
  295. }
  296. });
  297. },
  298. async goSafeAccess(){
  299. if(!this.param.detail.remark){
  300. uni.showToast({
  301. title: '请输入执行描述',
  302. icon:"none",
  303. mask:true,
  304. duration: 2000
  305. });
  306. return
  307. }
  308. if(this.control.isUpload==1){
  309. if(!this.upList[0]){
  310. uni.showToast({
  311. title: '请上传执行材料',
  312. icon:"none",
  313. mask:true,
  314. duration: 2000
  315. });
  316. return
  317. }
  318. }
  319. let _this = this;
  320. let obj = {
  321. }
  322. let imgName=[];
  323. let imgUrl=[];
  324. let imgType=[];
  325. _this.upList.forEach(function (item,index) {
  326. imgName.push(item.name)
  327. imgUrl.push(item.realUrl)
  328. imgType.push(item.type)
  329. })
  330. _this.param.detail.imgName=imgName.join(',')
  331. _this.param.detail.imgUrl=imgUrl.join(',')
  332. _this.param.detail.imgType=imgType.join(',')
  333. if(this.messageUserId){
  334. _this.param.messageUserId = this.messageUserId
  335. }
  336. console.log(_this.param)
  337. const {data} = await gradingControlAdd(_this.param)
  338. if(data.code==200){
  339. uni.showToast({
  340. title: '提交成功!',
  341. icon:"none",
  342. mask:true,
  343. duration: 2000
  344. });
  345. setTimeout(function(){
  346. uni.navigateBack();
  347. },2000);
  348. }
  349. },
  350. }
  351. }
  352. </script>
  353. <style lang="stylus" scoped>
  354. #accessQualification{
  355. height:100%;
  356. display flex
  357. flex-direction column
  358. .info-max-box{
  359. flex:1;
  360. overflow: scroll
  361. .for-big-box:last-child{
  362. margin-bottom:180rpx;
  363. }
  364. /* 列表 */
  365. .list{
  366. padding 0 20rpx;
  367. box-sizing border-box;
  368. .list_li{
  369. height auto;
  370. .list_li_t{
  371. height :80rpx;
  372. display flex;
  373. justify-content flex-start;
  374. align-items :center;
  375. .list_li_t_l{
  376. width: 80rpx;
  377. height: 30rpx;
  378. font-size: 24rpx;
  379. font-family: PingFang SC;
  380. font-weight: 500;
  381. color: #EE3A3A;
  382. line-height: 30rpx;
  383. border: 2rpx solid #EE3A3A;
  384. border-radius: 6rpx;
  385. text-align center;
  386. }
  387. .list_li_t_c{
  388. font-size: 28rpx;
  389. font-family: PingFang SC;
  390. font-weight: 500;
  391. color: #333333;
  392. line-height: 30rpx;
  393. margin 0 32rpx 0 16rpx;
  394. }
  395. .list_li_t_r{
  396. font-size: 28rpx;
  397. font-family: PingFang SC;
  398. font-weight: 500;
  399. color: #999999;
  400. line-height: 30rpx;
  401. }
  402. }
  403. .list_li_b{
  404. overflow :hidden;
  405. width 710rpx;
  406. height auto;
  407. background: #FFFFFF;
  408. border-radius: 20rpx;
  409. padding :0 14rpx;
  410. box-sizing :border-box;
  411. .list_li_b_t{
  412. overflow :hidden;
  413. .list_li_b_t_t{
  414. display flex;
  415. justify-content flex-start;
  416. margin :24rpx 0 18rpx 0;
  417. .list_li_b_t_t_n{
  418. flex:1;
  419. width:655rpx;
  420. display flex;
  421. justify-content flex-start;
  422. .list_li_b_t_t_l{
  423. width :100rpx;
  424. height :30rpx;
  425. font-size: 24rpx;
  426. font-family: PingFang SC;
  427. font-weight: 500;
  428. /* color: #0183FA; */
  429. line-height: 30rpx;
  430. /* background: rgba(1,131,250,0.2); */
  431. border-radius: 6rpx;
  432. text-align :center;
  433. }
  434. .list_li_b_t_t_c{
  435. font-size: 28rpx;
  436. font-family: PingFang SC;
  437. font-weight: 500;
  438. color: #333333;
  439. line-height: 28rpx;
  440. margin :0 16rpx 0 12rpx;
  441. }
  442. .list_li_b_t_t_r{
  443. font-size: 24rpx;
  444. font-family: PingFang SC;
  445. font-weight: 500;
  446. color: #EE3A3A;
  447. line-height: 24rpx;
  448. }
  449. .list_li_b_t_t_rr{
  450. flex:1;
  451. text-align:right;
  452. font-family: PingFang SC;
  453. font-weight: 500;
  454. color:#999;
  455. font-size: 24rpx;
  456. line-height: 24rpx;
  457. }
  458. }
  459. /* 日管控 */
  460. .purple{
  461. color: #AC20E0;
  462. background: rgba(172,32,224,0.2);
  463. }
  464. /* 周管控 */
  465. .blue{
  466. color: #0183FA;
  467. background: rgba(1,131,250,0.2);
  468. }
  469. /* 月管控 */
  470. .orange{
  471. color: #FA8801;
  472. background: rgba(250,136,1,0.2);
  473. }
  474. /* 年管控 */
  475. .green{
  476. color: #11BA25;
  477. background: rgba(17,186,37,0.2);
  478. }
  479. >img{
  480. width: 12rpx;
  481. height: 24rpx;
  482. }
  483. }
  484. .list_li_b_t_b{
  485. font-size: 28rpx;
  486. font-family: PingFang SC;
  487. font-weight: 500;
  488. color: #999999;
  489. line-height: 48rpx;
  490. margin-bottom :14rpx;
  491. }
  492. }
  493. .flex-view{
  494. display:flex;
  495. view{
  496. font-size:28rpx;
  497. line-height:28rpx;
  498. margin-top:28rpx;
  499. }
  500. view:nth-child(1){
  501. width:220rpx;
  502. }
  503. view:nth-child(2){
  504. width:460rpx;
  505. word-wrap:break-word;
  506. word-break:break-all;
  507. overflow: hidden;
  508. color:#999;
  509. }
  510. }
  511. .list_li_b_b{
  512. font-size: 28rpx;
  513. font-family: PingFang SC;
  514. font-weight: 500;
  515. color: #333333;
  516. line-height: 28rpx;
  517. >label{
  518. font-size: 28rpx;
  519. font-family: PingFang SC;
  520. font-weight: 500;
  521. color: #999999;
  522. line-height: 28rpx;
  523. }
  524. }
  525. .list_li_b_b2{
  526. font-size: 28rpx;
  527. font-family: PingFang SC;
  528. font-weight: 500;
  529. color: #333333;
  530. line-height: 28rpx;
  531. margin-top :32rpx;
  532. }
  533. .list_li_b_b3{
  534. width: 640rpx;
  535. height: 250rpx;
  536. border: 1rpx solid #E0E0E0;
  537. border-radius: 10rpx;
  538. margin :32rpx 0 0 10rpx;
  539. padding :25rpx 18rpx;
  540. box-sizing :border-box;
  541. }
  542. .placeholder-style{
  543. font-size: 24rpx;
  544. font-family: PingFang SC;
  545. font-weight: 500;
  546. color: #CCCCCC;
  547. line-height: 24rpx;
  548. }
  549. .list_li_b_b4{
  550. font-size: 28rpx;
  551. font-family: PingFang SC;
  552. font-weight: 500;
  553. color: #333333;
  554. line-height: 60rpx;
  555. margin-top :30rpx;
  556. margin-bottom :52rpx;
  557. >label{
  558. display :inline-block;
  559. width: 300rpx;
  560. height: 60rpx;
  561. border: 1rpx solid #0183FA;
  562. border-radius: 10rpx;
  563. text-align :center;
  564. margin-left :22rpx;
  565. font-size: 28rpx;
  566. font-family: PingFang SC;
  567. font-weight: 500;
  568. color: #0183FA;
  569. line-height: 60rpx;
  570. }
  571. }
  572. .list_li_b_b5{
  573. font-size: 28rpx;
  574. font-family: PingFang SC;
  575. font-weight: 500;
  576. color: #333333;
  577. line-height: 28rpx;
  578. margin-top :30rpx;
  579. margin-bottom 20rpx;
  580. >label{
  581. font-size: 28rpx;
  582. font-family: PingFang SC;
  583. font-weight: 500;
  584. color: #999999;
  585. line-height: 28rpx;
  586. }
  587. }
  588. .list_li_b_b6{
  589. display flex;
  590. margin-bottom:20rpx;
  591. view:nth-child(1){
  592. flex:1;
  593. line-height:30rpx;
  594. margin:15rpx 0 15rpx 15rpx;
  595. }
  596. view:nth-child(2){
  597. height:60rpx;
  598. width:60rpx;
  599. margin:0 20rpx 0 60rpx;
  600. img{
  601. height:30rpx;
  602. width:30rpx;
  603. margin:15rpx;
  604. }
  605. }
  606. }
  607. }
  608. }
  609. }
  610. /*暂无数据*/
  611. .get-null-box{
  612. height:100rpx;
  613. line-height:100rpx;
  614. color:#999;
  615. text-align center
  616. }
  617. }
  618. .bottom-button-box{
  619. border-radius:20rpx;
  620. margin:20rpx 50rpx;
  621. width: 650rpx;
  622. height: 100rpx;
  623. line-height: 100rpx;
  624. background: #0183FA;
  625. font-size: 30rpx;
  626. color: #FFFFFF;
  627. text-align center;
  628. }
  629. }
  630. </style>