gradingControlAdd.vue 17 KB

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