casuallyPat.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. <!-- 随手拍 -->
  2. <template>
  3. <view id="casuallyPat">
  4. <view class="casuallyPatList-page-go" :class="casuallyNum>0?'casuallyPatList-page-go-num':''" v-if="casuallyType" @click="goPage">
  5. <view>收到随手拍</view>
  6. <view>未处理{{casuallyNum}}条</view>
  7. <img src="@/images/icon_04.png">
  8. </view>
  9. <view class="casuallyPat-page">
  10. <view class="picker-box">
  11. <view class="left-box">实验室:</view>
  12. <view class="right-box">
  13. <picker @change="bindPickerChange" :value="laboratoryIndex" :range="laboratory">
  14. <view class="right-min-box">
  15. <view :class="{'colorA':newData.laboratory=='请选择实验室'}">{{newData.laboratory}}</view>
  16. <img src="@/images/icon_06.png">
  17. </view>
  18. </picker>
  19. </view>
  20. </view>
  21. <view class="up-img-box">
  22. <view class="title-view">照片:</view>
  23. <view class="img-max-box">
  24. <view class="img-box" v-for="(item,index) in newData.imgList" :key="index">
  25. <img class="img-data" :src="item">
  26. <img class="position-img" src="@/images/icon_ssp_closure.png" @click="delImg(index)">
  27. </view>
  28. <img class="add-button" src="@/images/icon_07.png" @click="selectImage" v-if="newData.imgList.length<9">
  29. </view>
  30. </view>
  31. <view class="input-box">
  32. <view class="left-box">描述:</view>
  33. <textarea v-model="newData.text" maxlength="200" placeholder="请输入描述"></textarea>
  34. </view>
  35. </view>
  36. <view class="up-button-box" @click="upDataButton">提交</view>
  37. </view>
  38. </template>
  39. <script>
  40. import { config } from '@/api/request/config.js'
  41. import { getSubjectDict,addPhotoNote,myIsadmin } from '@/api/index.js'
  42. import { appReceivePhotoNote } from '@/api/index.js'
  43. export default {
  44. data() {
  45. return {
  46. userType:0,
  47. casuallyType:false,
  48. //收到未处理随手拍数量
  49. casuallyNum:"",
  50. laboratory:['请选择实验室'],
  51. laboratoryList:[],
  52. laboratoryIndex:0,
  53. newData:{
  54. laboratory:"请选择实验室",
  55. text:"",
  56. imgList:[],
  57. realImgList:[]
  58. }
  59. }
  60. },
  61. onLoad() {
  62. this.userType = uni.getStorageSync('userType')
  63. },
  64. onShow(){
  65. this.myIsadmin();
  66. this.getSubjectDict();
  67. if(this.userType == 1){
  68. this.appReceivePhotoNote();
  69. }
  70. },
  71. methods: {
  72. goPage(){
  73. uni.navigateTo({
  74. url: '/pages_manage/workbench/receiveCasuallyPat/receiveCasuallyPat',
  75. });
  76. },
  77. //获取管理员工作台随手拍数量数据
  78. async appReceivePhotoNote(){
  79. const {data} = await appReceivePhotoNote();
  80. if(data.code == 200){
  81. this.casuallyNum = data.data.photoCount;
  82. }
  83. },
  84. //提交按钮
  85. upDataButton(){
  86. let self = this;
  87. if(self.newData.laboratory == '请选择实验室'){
  88. uni.showToast({
  89. title: '请选择实验室',
  90. icon:"none",
  91. mask:true,
  92. duration: 2000
  93. });
  94. return
  95. }
  96. if(!self.newData.text){
  97. uni.showToast({
  98. title: '请输入描述信息',
  99. icon:"none",
  100. mask:true,
  101. duration: 2000
  102. });
  103. return
  104. }
  105. if(!self.newData.imgList[0]){
  106. uni.showToast({
  107. title: '请添加图片',
  108. icon:"none",
  109. mask:true,
  110. duration: 2000
  111. });
  112. return
  113. }
  114. uni.showModal({
  115. content: '确认要提交吗?',
  116. cancelColor:"#999",
  117. confirmColor:"#0183FA",
  118. success: function (res) {
  119. if (res.confirm) {
  120. self.addPhotoNote();
  121. console.log('用户点击确定');
  122. } else if (res.cancel) {
  123. console.log('用户点击取消');
  124. }
  125. }
  126. });
  127. },
  128. async myIsadmin(){
  129. let self = this;
  130. let {data} = await myIsadmin()
  131. if(data.code == 200){
  132. this.casuallyType = data.data;
  133. }
  134. },
  135. // 随手拍实验室列表
  136. async getSubjectDict(){
  137. let self = this;
  138. let {data} = await getSubjectDict()
  139. if(data.code == 200){
  140. if(data.data[0]){
  141. let list = [];
  142. for(let i=0;i<data.data.length;i++){
  143. list.push(data.data[i].name);
  144. }
  145. this.laboratory = list;
  146. this.laboratoryList = data.data;
  147. }
  148. // this.violationData = data.data;
  149. }
  150. },
  151. // 随手拍提交
  152. async addPhotoNote(){
  153. let self = this;
  154. let obj = {
  155. imgUrls:self.newData.realImgList,
  156. subjectId:self.laboratoryList[self.laboratoryIndex].id,
  157. describe:self.newData.text,
  158. }
  159. let {data} = await addPhotoNote(obj)
  160. if(data.code == 200){
  161. uni.showToast({
  162. title: '提交成功',
  163. icon:"none",
  164. mask:true,
  165. duration: 2000
  166. });
  167. setTimeout(function(){
  168. uni.navigateBack();
  169. },2000);
  170. }
  171. },
  172. //实验室选择器
  173. bindPickerChange(e){
  174. this.laboratoryIndex = e.target.value;
  175. this.newData.laboratory = this.laboratory[this.laboratoryIndex];
  176. },
  177. // 图片上传
  178. selectImage(index) {
  179. let self = this;
  180. if(self.newData.imgList.length>4){
  181. uni.showToast({
  182. title: '最多上传5张图片',
  183. icon:"none",
  184. mask:true,
  185. duration: 2000
  186. });
  187. return
  188. }
  189. wx.chooseImage({
  190. count: 1,
  191. sizeType: ["original", "compressed"],
  192. sourceType: ["album", "camera"],
  193. success: function(res) {
  194. console.log(res)
  195. let tempFilePaths = res.tempFilePaths[0];
  196. self.uploadImg(tempFilePaths,index);
  197. }
  198. });
  199. },
  200. async uploadImg(tempFilePaths,index){
  201. var self = this;
  202. uni.showLoading({
  203. title: '上传中',
  204. mask: true
  205. });
  206. uni.uploadFile({
  207. url: config.base_url+'/file/upload', //仅为示例,非真实的接口地址
  208. header:{'Authorization':uni.getStorageSync('token')},
  209. filePath: tempFilePaths,
  210. name: 'file',
  211. formData: {
  212. 'user': 'test'
  213. },
  214. success: (uploadFileRes) => {
  215. let res = JSON.parse(uploadFileRes.data);
  216. if(res.code == 200){
  217. var url=config.base_url+res.data.url;
  218. url=url.replace("//","/").replace("https:/","https://").replace("http:/","http://");
  219. self.newData.imgList.push(url);
  220. self.newData.realImgList.push(res.data.url)
  221. }else{
  222. uni.showToast({
  223. title: res.msg,
  224. icon:"none",
  225. mask:true,
  226. duration: 2000
  227. });
  228. }
  229. },
  230. fail: err => {},
  231. complete: () => {
  232. uni.hideLoading()
  233. }
  234. });
  235. },
  236. //删除图片
  237. delImg(index){
  238. this.newData.imgList.splice(index,1);
  239. },
  240. }
  241. }
  242. </script>
  243. <style lang="stylus" scoped>
  244. #casuallyPat{
  245. height:100%;
  246. width:100%;
  247. background #f5f5f5
  248. overflow-y scroll
  249. .casuallyPatList-page-go-num{
  250. background rgba(249,95,95,0.2)!important;
  251. view:nth-child(2){
  252. color:#F95F5F!important;
  253. }
  254. }
  255. .casuallyPatList-page-go{
  256. background rgba(0,0,0,0.1);
  257. height:80rpx;
  258. display flex
  259. view{
  260. font-size:28rpx;
  261. line-height:80rpx;
  262. }
  263. view:nth-child(1){
  264. margin-left:21rpx;
  265. flex:1;
  266. color:#333;
  267. }
  268. view:nth-child(2){
  269. color:#333;
  270. margin-right:30rpx;
  271. }
  272. img:nth-child(3){
  273. margin:29rpx 20rpx 0 0;
  274. width:12rpx;
  275. height:24rpx;
  276. }
  277. }
  278. .casuallyPat-page{
  279. background #fff
  280. margin:20rpx;
  281. overflow hidden
  282. border-radius:20rpx;
  283. padding:30rpx;
  284. .picker-box{
  285. height:80rpx;
  286. display flex
  287. .left-box{
  288. width:140rpx;
  289. line-height:80rpx;
  290. font-size: 30rpx;
  291. color:#333;
  292. }
  293. .right-box{
  294. flex:1;
  295. width:470rpx;
  296. .right-min-box{
  297. display: flex;
  298. height:76rpx;
  299. border:2rpx solid #E0E0E0;
  300. border-radius: 10rpx;
  301. .colorA{
  302. color:#999!important;
  303. }
  304. view{
  305. flex:1;
  306. font-size: 24rpx;
  307. color: #333;
  308. margin-left:22rpx;
  309. line-height:78rpx;
  310. }
  311. img{
  312. width:24rpx;
  313. height:12rpx;
  314. margin:32rpx 16rpx 0 0;
  315. }
  316. }
  317. }
  318. }
  319. .input-box{
  320. height:250rpx;
  321. display flex
  322. margin-top:30rpx;
  323. .left-box{
  324. width:140rpx;
  325. line-height:80rpx;
  326. font-size: 30rpx;
  327. color:#333;
  328. }
  329. textarea{
  330. width:470rpx;
  331. border-radius: 10rpx;
  332. border:2rpx solid #E0E0E0;
  333. height:206rpx;
  334. padding:20rpx;
  335. font-size: 24rpx;
  336. color: #333;
  337. }
  338. }
  339. .up-img-box{
  340. display flex
  341. margin-top:30rpx;
  342. .title-view{
  343. width:140rpx;
  344. line-height:80rpx;
  345. font-size: 30rpx;
  346. color:#333;
  347. }
  348. .img-max-box{
  349. width:510rpx;
  350. .img-box{
  351. display inline-block
  352. height:150rpx;
  353. width:150rpx;
  354. position relative
  355. margin:0 20rpx 20rpx 0;
  356. .img-data{
  357. height:150rpx;
  358. width:150rpx;
  359. }
  360. .position-img{
  361. position absolute
  362. right:0;
  363. top:0;
  364. width:36rpx;
  365. height:36rpx;
  366. }
  367. }
  368. .add-button{
  369. display inline-block
  370. height:150rpx;
  371. width:150rpx;
  372. }
  373. }
  374. }
  375. }
  376. .up-button-box{
  377. width: 550rpx;
  378. height: 80rpx;
  379. line-height: 80rpx;
  380. background: #0183FA;
  381. border-radius: 20rpx;
  382. font-size:30rpx;
  383. margin:80rpx auto;
  384. text-align center;
  385. color:#fff;
  386. }
  387. }
  388. </style>