addTask.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  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.showLoading({
  162. title: "加载中",
  163. mask: true,
  164. })
  165. API.addErr(this.taskInfo).then((res) => {
  166. uni.showModal({
  167. title: '提示',
  168. showCancel: false,
  169. content: "上报成功",
  170. success: res1 => {
  171. if (res1.confirm) {
  172. uni.navigateBack()
  173. } else if (res1.cancel) {
  174. //('用户点击取消');
  175. }
  176. }
  177. })
  178. uni.hideLoading();
  179. }).catch(error => {
  180. uni.hideLoading();
  181. uni.showToast({
  182. title: error,
  183. icon: "none"
  184. })
  185. })
  186. },
  187. findByCatalogName(obj, listName) {
  188. API.findByCatalogName(obj).then((res) => {
  189. var arr = res.data.dataDictionaryList
  190. this[listName] = arr
  191. }).catch(error => {
  192. uni.hideLoading();
  193. uni.showToast({
  194. title: error,
  195. icon: "none"
  196. })
  197. })
  198. },
  199. getteamMembers() {
  200. uni.showLoading({
  201. title: "加载中",
  202. mask: true,
  203. })
  204. API.teamMembers().then((res) => {
  205. var arr = res.data.memberList
  206. this.memberList = arr
  207. this.memberList.forEach(item => {
  208. if (item.id == this.jphelp.getPersonInfo().id) {
  209. item.checked = true
  210. } else {
  211. item.checked = false
  212. }
  213. })
  214. uni.hideLoading();
  215. }).catch(error => {
  216. uni.hideLoading();
  217. uni.showToast({
  218. title: error,
  219. icon: "none"
  220. })
  221. })
  222. },
  223. selectTaskInfoCodeConfirm(e) {
  224. console.log(e)
  225. this.codeN = e[0].label
  226. this.taskInfo.code = e[0].value
  227. },
  228. selectTaskInfoCodeBtn() {
  229. if (this.taskInfo.code) {
  230. //this.selectTaskInfoCodeValue=[parseInt(this.bindInfo.type)-1]
  231. var i = this.codeList.findIndex(item => {
  232. return item.value == this.taskInfo.code
  233. })
  234. this.selectTaskInfoCodeValue = [i]
  235. }
  236. this.selectTaskInfoCode = true;
  237. },
  238. gotoSelectStation() {
  239. uni.navigateTo({
  240. url: '/pages/task/selectStation',
  241. events: {
  242. // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
  243. acceptDataFromOpenerPage: (item) => {
  244. console.log(item)
  245. this.taskInfo.stationId = item.item.id
  246. this.stationName = item.item.name
  247. this.$forceUpdate()
  248. },
  249. }
  250. })
  251. }
  252. }
  253. }
  254. </script>
  255. <style lang="scss">
  256. .jpmain {
  257. padding-bottom: 120rpx;
  258. }
  259. .list {
  260. background-color: rgba(255, 255, 255, 1);
  261. border-radius: 16rpx;
  262. margin: 20rpx;
  263. .item:not(:last-child) {
  264. border-bottom: 2rpx solid rgba(232, 232, 232, 1);
  265. }
  266. .item {
  267. padding: 24rpx;
  268. display: flex;
  269. justify-content: space-between;
  270. .name {
  271. width: 40%;
  272. font-size: 32rpx;
  273. color: #777777;
  274. span {
  275. color: red
  276. }
  277. white-space: pre;
  278. }
  279. .value {
  280. font-size: 32rpx;
  281. width: 60%;
  282. display: flex;
  283. justify-content: space-between;
  284. input::placeholder {
  285. color: #AAAAAA;
  286. }
  287. .img {
  288. width: 40rpx;
  289. height: 40rpx;
  290. }
  291. .textarea {
  292. background-color: rgba(241, 242, 245, 1);
  293. width: 100%;
  294. border-radius: 8rpx;
  295. }
  296. }
  297. }
  298. .item-plus {
  299. flex-direction: column;
  300. .value,
  301. .name {
  302. width: 100%;
  303. }
  304. .name {
  305. padding-bottom: 32rpx;
  306. }
  307. }
  308. }
  309. .floating-button {
  310. z-index: 999;
  311. position: fixed;
  312. bottom: 0;
  313. width: 100%;
  314. display: flex;
  315. height: 120rpx;
  316. justify-content: center;
  317. background-color: rgba(255, 255, 255, 1);
  318. .button {
  319. margin-top: 24rpx;
  320. border-radius: 50px;
  321. height: 80rpx;
  322. width: 80%;
  323. display: flex;
  324. align-items: center;
  325. justify-content: center;
  326. padding: 12rpx;
  327. background-color: rgba(22, 119, 255, 1);
  328. color: rgba(255, 255, 255, 1);
  329. font-size: 36rpx;
  330. }
  331. }
  332. .textareaclass {
  333. padding: 16rpx
  334. }
  335. </style>