addTask.vue 8.3 KB

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