casuallyPat.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  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. } else if (res.cancel) {
  122. }
  123. }
  124. });
  125. },
  126. async myIsadmin(){
  127. let self = this;
  128. let {data} = await myIsadmin()
  129. if(data.code == 200){
  130. this.casuallyType = data.data;
  131. }
  132. },
  133. // 随手拍实验室列表
  134. async getSubjectDict(){
  135. let self = this;
  136. let {data} = await getSubjectDict()
  137. if(data.code == 200){
  138. if(data.data[0]){
  139. let list = [];
  140. for(let i=0;i<data.data.length;i++){
  141. list.push(data.data[i].name);
  142. }
  143. this.laboratory = list;
  144. this.laboratoryList = data.data;
  145. }
  146. // this.violationData = data.data;
  147. }
  148. },
  149. // 随手拍提交
  150. async addPhotoNote(){
  151. let self = this;
  152. let obj = {
  153. imgUrls:self.newData.realImgList,
  154. subjectId:self.laboratoryList[self.laboratoryIndex].id,
  155. describe:self.newData.text,
  156. }
  157. let {data} = await addPhotoNote(obj)
  158. if(data.code == 200){
  159. uni.showToast({
  160. title: '提交成功',
  161. icon:"none",
  162. mask:true,
  163. duration: 2000
  164. });
  165. setTimeout(function(){
  166. uni.navigateBack();
  167. },2000);
  168. }
  169. },
  170. //实验室选择器
  171. bindPickerChange(e){
  172. this.laboratoryIndex = e.target.value;
  173. this.newData.laboratory = this.laboratory[this.laboratoryIndex];
  174. },
  175. // 图片上传
  176. selectImage(index) {
  177. let self = this;
  178. if(self.newData.imgList.length>4){
  179. uni.showToast({
  180. title: '最多上传5张图片',
  181. icon:"none",
  182. mask:true,
  183. duration: 2000
  184. });
  185. return
  186. }
  187. wx.chooseImage({
  188. count: 1,
  189. sizeType: ["original", "compressed"],
  190. sourceType: ["album", "camera"],
  191. success: function(res) {
  192. let tempFilePaths = res.tempFilePaths[0];
  193. self.uploadImg(tempFilePaths,index);
  194. }
  195. });
  196. },
  197. async uploadImg(tempFilePaths,index){
  198. var self = this;
  199. uni.showLoading({
  200. title: '上传中',
  201. mask: true
  202. });
  203. uni.uploadFile({
  204. url: config.base_url+'/base/file/upload', //仅为示例,非真实的接口地址
  205. header:{'Authorization':uni.getStorageSync('token')},
  206. filePath: tempFilePaths,
  207. name: 'file',
  208. formData: {
  209. 'user': 'test'
  210. },
  211. success: (uploadFileRes) => {
  212. let res = JSON.parse(uploadFileRes.data);
  213. if(res.code == 200){
  214. var url=config.base_url+res.data.url;
  215. url=url.replace("//","/").replace("https:/","https://").replace("http:/","http://");
  216. self.newData.imgList.push(url);
  217. self.newData.realImgList.push(res.data.url)
  218. }else{
  219. uni.showToast({
  220. title: res.msg,
  221. icon:"none",
  222. mask:true,
  223. duration: 2000
  224. });
  225. }
  226. },
  227. fail: err => {},
  228. complete: () => {
  229. uni.hideLoading()
  230. }
  231. });
  232. },
  233. //删除图片
  234. delImg(index){
  235. this.newData.imgList.splice(index,1);
  236. },
  237. }
  238. }
  239. </script>
  240. <style lang="stylus" scoped>
  241. #casuallyPat{
  242. height:100%;
  243. width:100%;
  244. background #f5f5f5
  245. overflow-y scroll
  246. .casuallyPatList-page-go-num{
  247. background rgba(249,95,95,0.2)!important;
  248. view:nth-child(2){
  249. color:#F95F5F!important;
  250. }
  251. }
  252. .casuallyPatList-page-go{
  253. background rgba(0,0,0,0.1);
  254. height:80rpx;
  255. display flex
  256. view{
  257. font-size:28rpx;
  258. line-height:80rpx;
  259. }
  260. view:nth-child(1){
  261. margin-left:21rpx;
  262. flex:1;
  263. color:#333;
  264. }
  265. view:nth-child(2){
  266. color:#333;
  267. margin-right:30rpx;
  268. }
  269. img:nth-child(3){
  270. margin:29rpx 20rpx 0 0;
  271. width:12rpx;
  272. height:24rpx;
  273. }
  274. }
  275. .casuallyPat-page{
  276. background #fff
  277. margin:20rpx;
  278. overflow hidden
  279. border-radius:20rpx;
  280. padding:30rpx;
  281. .picker-box{
  282. height:80rpx;
  283. display flex
  284. .left-box{
  285. width:140rpx;
  286. line-height:80rpx;
  287. font-size: 30rpx;
  288. color:#333;
  289. }
  290. .right-box{
  291. flex:1;
  292. width:470rpx;
  293. .right-min-box{
  294. display: flex;
  295. height:76rpx;
  296. border:2rpx solid #E0E0E0;
  297. border-radius: 10rpx;
  298. .colorA{
  299. color:#999!important;
  300. }
  301. view{
  302. flex:1;
  303. font-size: 24rpx;
  304. color: #333;
  305. margin-left:22rpx;
  306. line-height:78rpx;
  307. }
  308. img{
  309. width:24rpx;
  310. height:12rpx;
  311. margin:32rpx 16rpx 0 0;
  312. }
  313. }
  314. }
  315. }
  316. .input-box{
  317. height:250rpx;
  318. display flex
  319. margin-top:30rpx;
  320. .left-box{
  321. width:140rpx;
  322. line-height:80rpx;
  323. font-size: 30rpx;
  324. color:#333;
  325. }
  326. textarea{
  327. width:470rpx;
  328. border-radius: 10rpx;
  329. border:2rpx solid #E0E0E0;
  330. height:206rpx;
  331. padding:20rpx;
  332. font-size: 24rpx;
  333. color: #333;
  334. }
  335. }
  336. .up-img-box{
  337. display flex
  338. margin-top:30rpx;
  339. .title-view{
  340. width:140rpx;
  341. line-height:80rpx;
  342. font-size: 30rpx;
  343. color:#333;
  344. }
  345. .img-max-box{
  346. width:510rpx;
  347. .img-box{
  348. display inline-block
  349. height:150rpx;
  350. width:150rpx;
  351. position relative
  352. margin:0 20rpx 20rpx 0;
  353. .img-data{
  354. height:150rpx;
  355. width:150rpx;
  356. }
  357. .position-img{
  358. position absolute
  359. right:0;
  360. top:0;
  361. width:36rpx;
  362. height:36rpx;
  363. }
  364. }
  365. .add-button{
  366. display inline-block
  367. height:150rpx;
  368. width:150rpx;
  369. }
  370. }
  371. }
  372. }
  373. .up-button-box{
  374. width: 550rpx;
  375. height: 80rpx;
  376. line-height: 80rpx;
  377. background: #0183FA;
  378. border-radius: 20rpx;
  379. font-size:30rpx;
  380. margin:80rpx auto;
  381. text-align center;
  382. color:#fff;
  383. }
  384. }
  385. </style>