gradingControlAdd.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  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="@/pages_manage/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 } from '@/api/apiDemo/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. let text = res.tempFiles[0].path.substring(res.tempFiles[0].path.lastIndexOf('.') + 1);
  236. if(text != 'png' && text != 'jpg' && text != 'jpeg' && text!= 'gif' && text != 'pdf' && text != 'doc' && text != 'docx'){
  237. uni.showToast({
  238. title: '仅支持png/jpg/jpeg/gif/pdf/doc/docx类型的文件上传',
  239. icon:"none",
  240. mask:true,
  241. duration: 2000
  242. });
  243. return
  244. }
  245. let upObj = {
  246. name:res.tempFiles[0].name,
  247. path:res.tempFiles[0].path,
  248. type:text,
  249. }
  250. self.upDataFunction(item,upObj);
  251. }
  252. })
  253. },
  254. async upDataFunction(item,upObj){
  255. var self = this;
  256. uni.showLoading({
  257. title: '上传中',
  258. mask: true
  259. });
  260. uni.uploadFile({
  261. url: config.base_url+'/base/file/upload', //仅为示例,非真实的接口地址
  262. header:{'Authorization':uni.getStorageSync('token')},
  263. filePath: upObj.path,
  264. name: 'file',
  265. formData: {
  266. 'user': 'test'
  267. },
  268. success: (uploadFileRes) => {
  269. let res = JSON.parse(uploadFileRes.data);
  270. if(res.code == 200){
  271. let obj = {
  272. name:upObj.name,
  273. url:config.base_url+res.data.url,
  274. realUrl:res.data.url,
  275. type:upObj.type
  276. }
  277. this.upList.push(obj);
  278. this.$forceUpdate();
  279. console.log(this.upList)
  280. }else{
  281. uni.showToast({
  282. title: res.msg,
  283. icon:"none",
  284. mask:true,
  285. duration: 2000
  286. });
  287. }
  288. },
  289. fail: err => {},
  290. complete: () => {
  291. uni.hideLoading()
  292. }
  293. });
  294. },
  295. async goSafeAccess(){
  296. if(!this.param.detail.remark){
  297. uni.showToast({
  298. title: '请输入执行描述',
  299. icon:"none",
  300. mask:true,
  301. duration: 2000
  302. });
  303. return
  304. }
  305. if(this.control.isUpload==1){
  306. if(!this.upList[0]){
  307. uni.showToast({
  308. title: '请上传执行材料',
  309. icon:"none",
  310. mask:true,
  311. duration: 2000
  312. });
  313. return
  314. }
  315. }
  316. let _this = this;
  317. let obj = {
  318. }
  319. let imgName=[];
  320. let imgUrl=[];
  321. let imgType=[];
  322. _this.upList.forEach(function (item,index) {
  323. imgName.push(item.name)
  324. imgUrl.push(item.realUrl)
  325. imgType.push(item.type)
  326. })
  327. _this.param.detail.imgName=imgName.join(',')
  328. _this.param.detail.imgUrl=imgUrl.join(',')
  329. _this.param.detail.imgType=imgType.join(',')
  330. if(this.messageUserId){
  331. _this.param.messageUserId = this.messageUserId
  332. }
  333. console.log(_this.param)
  334. const {data} = await gradingControlAdd(_this.param)
  335. if(data.code==200){
  336. uni.showToast({
  337. title: '提交成功!',
  338. icon:"none",
  339. mask:true,
  340. duration: 2000
  341. });
  342. setTimeout(function(){
  343. uni.navigateBack();
  344. },2000);
  345. }
  346. },
  347. }
  348. }
  349. </script>
  350. <style lang="stylus" scoped>
  351. #accessQualification{
  352. height:100%;
  353. display flex
  354. flex-direction column
  355. .info-max-box{
  356. flex:1;
  357. overflow: scroll
  358. .for-big-box:last-child{
  359. margin-bottom:180rpx;
  360. }
  361. /* 列表 */
  362. .list{
  363. padding 0 20rpx;
  364. box-sizing border-box;
  365. .list_li{
  366. height auto;
  367. .list_li_t{
  368. height :80rpx;
  369. display flex;
  370. justify-content flex-start;
  371. align-items :center;
  372. .list_li_t_l{
  373. width: 80rpx;
  374. height: 30rpx;
  375. font-size: 24rpx;
  376. font-family: PingFang SC;
  377. font-weight: 500;
  378. color: #EE3A3A;
  379. line-height: 30rpx;
  380. border: 2rpx solid #EE3A3A;
  381. border-radius: 6rpx;
  382. text-align center;
  383. }
  384. .list_li_t_c{
  385. font-size: 28rpx;
  386. font-family: PingFang SC;
  387. font-weight: 500;
  388. color: #333333;
  389. line-height: 30rpx;
  390. margin 0 32rpx 0 16rpx;
  391. }
  392. .list_li_t_r{
  393. font-size: 28rpx;
  394. font-family: PingFang SC;
  395. font-weight: 500;
  396. color: #999999;
  397. line-height: 30rpx;
  398. }
  399. }
  400. .list_li_b{
  401. overflow :hidden;
  402. width 710rpx;
  403. height auto;
  404. background: #FFFFFF;
  405. border-radius: 20rpx;
  406. padding :0 14rpx;
  407. box-sizing :border-box;
  408. .list_li_b_t{
  409. overflow :hidden;
  410. .list_li_b_t_t{
  411. display flex;
  412. justify-content flex-start;
  413. margin :24rpx 0 18rpx 0;
  414. .list_li_b_t_t_n{
  415. flex:1;
  416. width:655rpx;
  417. display flex;
  418. justify-content flex-start;
  419. .list_li_b_t_t_l{
  420. width :100rpx;
  421. height :30rpx;
  422. font-size: 24rpx;
  423. font-family: PingFang SC;
  424. font-weight: 500;
  425. /* color: #0183FA; */
  426. line-height: 30rpx;
  427. /* background: rgba(1,131,250,0.2); */
  428. border-radius: 6rpx;
  429. text-align :center;
  430. }
  431. .list_li_b_t_t_c{
  432. font-size: 28rpx;
  433. font-family: PingFang SC;
  434. font-weight: 500;
  435. color: #333333;
  436. line-height: 28rpx;
  437. margin :0 16rpx 0 12rpx;
  438. }
  439. .list_li_b_t_t_r{
  440. font-size: 24rpx;
  441. font-family: PingFang SC;
  442. font-weight: 500;
  443. color: #EE3A3A;
  444. line-height: 24rpx;
  445. }
  446. .list_li_b_t_t_rr{
  447. flex:1;
  448. text-align:right;
  449. font-family: PingFang SC;
  450. font-weight: 500;
  451. color:#999;
  452. font-size: 24rpx;
  453. line-height: 24rpx;
  454. }
  455. }
  456. /* 日管控 */
  457. .purple{
  458. color: #AC20E0;
  459. background: rgba(172,32,224,0.2);
  460. }
  461. /* 周管控 */
  462. .blue{
  463. color: #0183FA;
  464. background: rgba(1,131,250,0.2);
  465. }
  466. /* 月管控 */
  467. .orange{
  468. color: #FA8801;
  469. background: rgba(250,136,1,0.2);
  470. }
  471. /* 年管控 */
  472. .green{
  473. color: #11BA25;
  474. background: rgba(17,186,37,0.2);
  475. }
  476. >img{
  477. width: 12rpx;
  478. height: 24rpx;
  479. }
  480. }
  481. .list_li_b_t_b{
  482. font-size: 28rpx;
  483. font-family: PingFang SC;
  484. font-weight: 500;
  485. color: #999999;
  486. line-height: 48rpx;
  487. margin-bottom :14rpx;
  488. }
  489. }
  490. .flex-view{
  491. display:flex;
  492. view{
  493. font-size:28rpx;
  494. line-height:28rpx;
  495. margin-top:28rpx;
  496. }
  497. view:nth-child(1){
  498. width:220rpx;
  499. }
  500. view:nth-child(2){
  501. width:460rpx;
  502. word-wrap:break-word;
  503. word-break:break-all;
  504. overflow: hidden;
  505. color:#999;
  506. }
  507. }
  508. .list_li_b_b{
  509. font-size: 28rpx;
  510. font-family: PingFang SC;
  511. font-weight: 500;
  512. color: #333333;
  513. line-height: 28rpx;
  514. >label{
  515. font-size: 28rpx;
  516. font-family: PingFang SC;
  517. font-weight: 500;
  518. color: #999999;
  519. line-height: 28rpx;
  520. }
  521. }
  522. .list_li_b_b2{
  523. font-size: 28rpx;
  524. font-family: PingFang SC;
  525. font-weight: 500;
  526. color: #333333;
  527. line-height: 28rpx;
  528. margin-top :32rpx;
  529. }
  530. .list_li_b_b3{
  531. width: 640rpx;
  532. height: 250rpx;
  533. border: 1rpx solid #E0E0E0;
  534. border-radius: 10rpx;
  535. margin :32rpx 0 0 10rpx;
  536. padding :25rpx 18rpx;
  537. box-sizing :border-box;
  538. }
  539. .placeholder-style{
  540. font-size: 24rpx;
  541. font-family: PingFang SC;
  542. font-weight: 500;
  543. color: #CCCCCC;
  544. line-height: 24rpx;
  545. }
  546. .list_li_b_b4{
  547. font-size: 28rpx;
  548. font-family: PingFang SC;
  549. font-weight: 500;
  550. color: #333333;
  551. line-height: 60rpx;
  552. margin-top :30rpx;
  553. margin-bottom :52rpx;
  554. >label{
  555. display :inline-block;
  556. width: 300rpx;
  557. height: 60rpx;
  558. border: 1rpx solid #0183FA;
  559. border-radius: 10rpx;
  560. text-align :center;
  561. margin-left :22rpx;
  562. font-size: 28rpx;
  563. font-family: PingFang SC;
  564. font-weight: 500;
  565. color: #0183FA;
  566. line-height: 60rpx;
  567. }
  568. }
  569. .list_li_b_b5{
  570. font-size: 28rpx;
  571. font-family: PingFang SC;
  572. font-weight: 500;
  573. color: #333333;
  574. line-height: 28rpx;
  575. margin-top :30rpx;
  576. margin-bottom 20rpx;
  577. >label{
  578. font-size: 28rpx;
  579. font-family: PingFang SC;
  580. font-weight: 500;
  581. color: #999999;
  582. line-height: 28rpx;
  583. }
  584. }
  585. .list_li_b_b6{
  586. display flex;
  587. margin-bottom:20rpx;
  588. view:nth-child(1){
  589. flex:1;
  590. line-height:30rpx;
  591. margin:15rpx 0 15rpx 15rpx;
  592. }
  593. view:nth-child(2){
  594. height:60rpx;
  595. width:60rpx;
  596. margin:0 20rpx 0 60rpx;
  597. img{
  598. height:30rpx;
  599. width:30rpx;
  600. margin:15rpx;
  601. }
  602. }
  603. }
  604. }
  605. }
  606. }
  607. /*暂无数据*/
  608. .get-null-box{
  609. height:100rpx;
  610. line-height:100rpx;
  611. color:#999;
  612. text-align center
  613. }
  614. }
  615. .bottom-button-box{
  616. border-radius:20rpx;
  617. margin:20rpx 50rpx;
  618. width: 650rpx;
  619. height: 100rpx;
  620. line-height: 100rpx;
  621. background: #0183FA;
  622. font-size: 30rpx;
  623. color: #FFFFFF;
  624. text-align center;
  625. }
  626. }
  627. </style>