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