gradingControlAdd.vue 17 KB

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