addTask.vue 7.9 KB

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