addTask.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <template>
  2. <view class="jpmain " >
  3. <u-navbar title="故障上报" title-color="#101010"></u-navbar>
  4. <view class="list" >
  5. <view class="item" >
  6. <view class="name">
  7. <span>*</span>选择地锁
  8. </view>
  9. <view class="value" @click="gotoSelectLock()">
  10. <view :style="taskInfo.lockId?'':'color:#BBB'"
  11. >{{taskInfo.lockId?lockName:'选择需要上报的地锁'}}</view>
  12. <u-icon name="arrow-right" size="24" color="#BBBBBB"></u-icon>
  13. </view>
  14. </view>
  15. <view class="item">
  16. <view class="name">
  17. 地锁编号
  18. </view>
  19. <view class="value">
  20. <view :style="taskInfo.lockId?'':'color:#BBB'"
  21. >{{taskInfo.lockId?lockNo:'选择需要上报的地锁'}}</view>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="list" >
  26. <view class="item" >
  27. <view class="name">
  28. <span>*</span>故障类型
  29. </view>
  30. <view class="value" @click="selectTaskInfoCodeBtn">
  31. <view :style="taskInfo.code?'':'color:#BBB'"
  32. >{{taskInfo.code?codeN:'请选择故障类型'}}</view>
  33. <u-icon name="arrow-right" size="24" color="#BBBBBB"></u-icon>
  34. </view>
  35. </view>
  36. <view class="item item-plus" >
  37. <view class="name">
  38. 问题描述
  39. </view>
  40. <view class="value" >
  41. <textarea placeholder="请简单描述处理内容"
  42. v-model="taskInfo.desc" placeholder-class="textareaclass"
  43. class="textarea"></textarea>
  44. </view>
  45. </view>
  46. <view class="item item-plus" >
  47. <view class="name">
  48. 上传图片
  49. </view>
  50. <view class="value" >
  51. <u-upload name="photoFile"
  52. ref="uUpload"
  53. :form-data="formData" :header="header" :action="action"
  54. :file-list="listPic" ></u-upload>
  55. </view>
  56. </view>
  57. </view>
  58. <u-select v-model="selectTaskInfoCode" :default-value="selectTaskInfoCodeValue"
  59. value-name="value" label-name="name" @confirm="selectTaskInfoCodeConfirm"
  60. :list="codeList"></u-select>
  61. <view class="floating-button">
  62. <view class="button" @click="submit" >
  63. 提交
  64. </view>
  65. </view>
  66. </view>
  67. </template>
  68. <script>
  69. import * as API from '@/apis/pagejs/pagesTask.js'
  70. export default {
  71. data() {
  72. return {
  73. listPic: [],
  74. action:"",
  75. formData:{
  76. },
  77. header:{
  78. },
  79. codeN:"",
  80. selectTaskInfoCode:false,
  81. selectTaskInfoCodeValue:[0],
  82. lockNo:"",
  83. lockName:"",
  84. taskInfo:{
  85. lockId:"",
  86. code:"",
  87. desc:"",
  88. images:"",
  89. },
  90. codeList:[]
  91. };
  92. },
  93. onLoad() {
  94. this.action=process.jphelp.BASE_URL+"uploadPicture"
  95. this.formData.subFolder="/floorlock/inspection/addTask"
  96. var token=this.jphelp.getToken()
  97. this.header={
  98. 'Authorization':token
  99. }
  100. this.findByCatalogName({
  101. catalogName:'设备故障类型'
  102. },"codeList")
  103. },
  104. methods:{
  105. submit(){
  106. if(!this.taskInfo.lockId){
  107. uni.showToast({
  108. title:"选择需要上报的地锁"
  109. })
  110. return
  111. }
  112. if(!this.taskInfo.code){
  113. uni.showToast({
  114. title:"请选择故障类型"
  115. })
  116. return
  117. }
  118. let files = [];
  119. // 通过filter,筛选出上传进度为100的文件(因为某些上传失败的文件,进度值不为100,这个是可选的操作)
  120. files = this.$refs.uUpload.lists.filter(val => {
  121. return val.progress == 100;
  122. })
  123. // 如果您不需要进行太多的处理,直接如下即可
  124. // files = this.$refs.uUpload.lists;
  125. //(files);
  126. var imgUrl=files.map(item=>{
  127. return item.response.data;
  128. })
  129. //(imgUrl);
  130. this.taskInfo.images = imgUrl.join(',');
  131. uni.showLoading({
  132. title: "加载中",
  133. mask: true,
  134. })
  135. API.addErr(this.taskInfo).then((res) => {
  136. uni.showModal({
  137. title: '提示',
  138. showCancel: false,
  139. content: "上报成功",
  140. success: res1 => {
  141. if (res1.confirm) {
  142. uni.navigateBack()
  143. } else if (res1.cancel) {
  144. //('用户点击取消');
  145. }
  146. }
  147. })
  148. uni.hideLoading();
  149. }).catch(error => {
  150. uni.hideLoading();
  151. uni.showToast({
  152. title: error,
  153. icon: "none"
  154. })
  155. })
  156. },
  157. findByCatalogName(obj,listName){
  158. uni.showLoading({
  159. title: "加载中",
  160. mask: true,
  161. })
  162. API.findByCatalogName(obj).then((res) => {
  163. var arr = res.data.dataDictionaryList
  164. this[listName] = arr
  165. uni.hideLoading();
  166. }).catch(error => {
  167. uni.hideLoading();
  168. uni.showToast({
  169. title: error,
  170. icon: "none"
  171. })
  172. })
  173. },
  174. selectTaskInfoCodeConfirm(e){
  175. console.log(e)
  176. this.codeN=e[0].label
  177. this.taskInfo.code=e[0].value
  178. },
  179. selectTaskInfoCodeBtn(){
  180. if(this.taskInfo.code){
  181. //this.selectTaskInfoCodeValue=[parseInt(this.bindInfo.type)-1]
  182. var i =this.codeList.findIndex(item=>{
  183. return item.value==this.taskInfo.code
  184. })
  185. this.selectTaskInfoCodeValue=[i]
  186. }
  187. this.selectTaskInfoCode=true;
  188. },
  189. gotoSelectLock(){
  190. uni.navigateTo({
  191. url: '/pages/task/selectLock',
  192. events: {
  193. // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
  194. acceptDataFromOpenerPage: (item)=>{
  195. console.log(item)
  196. this.taskInfo.lockId=item.item.id
  197. this.lockName=item.item.name
  198. this.lockNo=item.item.lockNo
  199. this.$forceUpdate()
  200. },
  201. }
  202. })
  203. }
  204. }
  205. }
  206. </script>
  207. <style lang="scss">
  208. .jpmain{padding-bottom: 120rpx;}
  209. .list{
  210. background-color: rgba(255,255,255,1);
  211. margin: 20rpx 0;
  212. .item:not(:last-child) {
  213. border-bottom:1px solid rgba(232,232,232,1);
  214. }
  215. .item{
  216. padding: 24rpx;
  217. display: flex;
  218. justify-content: space-between;
  219. .name{
  220. width: 40%;
  221. font-size: 32rpx;
  222. color: #777777;
  223. span{
  224. color:red
  225. }
  226. white-space: pre;
  227. }
  228. .value{
  229. font-size: 32rpx;
  230. width: 60%;
  231. display: flex;
  232. justify-content: space-between;
  233. input::placeholder{
  234. color:#AAAAAA;
  235. }
  236. .img{
  237. width: 40rpx;
  238. height: 40rpx;
  239. }
  240. .textarea{
  241. background-color: rgba(241,242,245,1);
  242. width: 100%;
  243. border-radius: 4px;
  244. }
  245. }
  246. }
  247. .item-plus{
  248. flex-direction: column;
  249. .value,.name{
  250. width: 100%;
  251. }
  252. .name{
  253. padding-bottom: 32rpx;
  254. }
  255. }
  256. }
  257. .floating-button {
  258. position: fixed;
  259. bottom: 0; /* 距离底部 20px */
  260. width: 100%;
  261. display: flex;
  262. height: 120rpx;
  263. justify-content: center;
  264. background-color: rgba(255,255,255,1);
  265. .button{
  266. margin-top: 24rpx;
  267. border-radius: 50px;
  268. height: 80rpx;
  269. width: 80%;
  270. display: flex;
  271. align-items: center;
  272. justify-content: center;
  273. padding:12rpx;
  274. background-color: rgba(22,119,255,1);
  275. color: rgba(255,255,255,1);
  276. font-size: 36rpx;
  277. }
  278. }
  279. .textareaclass{
  280. padding:16rpx
  281. }
  282. </style>