faultReport.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. <template>
  2. <view>
  3. <u-navbar title="故障上报" title-color="#101010"></u-navbar>
  4. <!-- 设备选择器 -->
  5. <u-select title="设备选择" v-model="show" mode="single-column" :list="deviceList" @confirm="deviceConfirm">
  6. </u-select>
  7. <view class="main">
  8. <!-- 故障设备 -->
  9. <view class="fault-equipment" @click="show=true">
  10. <view class="title">
  11. <text class="asterisk">*</text>故障设备
  12. </view>
  13. <view class="value">
  14. <view class="placeholder" v-if="!faultForm.deviceName">
  15. 请选择设备
  16. </view>
  17. <view v-else>
  18. {{faultForm.deviceName}}
  19. </view>
  20. <view class="icon">
  21. <u-icon name="arrow-right" color="#acacac"></u-icon>
  22. </view>
  23. </view>
  24. </view>
  25. <!-- 故障类型 -->
  26. <view class="fault-type">
  27. <view class="title">
  28. <text class="asterisk">*</text>请选择故障类型:
  29. </view>
  30. <view class="type">
  31. <view class="type-item" v-for="(item,index) in stateList" :key="index"
  32. :class="stateIndex==index ? 'item-checked' : ''" @click="stateClick(item,index)">
  33. {{item.label}}
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. <!-- 照片上传 -->
  39. <view class="picture-upload">
  40. <view class="title">
  41. 现场照片/视频(最多4张)
  42. </view>
  43. <view class="upload">
  44. <!-- <u-upload :action="action" :file-list="fileList" max-count="4" width="144" height="144"></u-upload> -->
  45. <u-upload max-count="4" name="photoFile" ref="uUpload" :form-data="formData" :header="header"
  46. :action="action" :file-list="fileList" width="144" height="144"></u-upload>
  47. </view>
  48. </view>
  49. <!-- 故障描述 -->
  50. <view class="fault-description">
  51. <view class="title">
  52. <text class="asterisk">*</text>故障描述
  53. </view>
  54. <view class="textarea">
  55. <textarea v-model="faultForm.content" placeholder="请详细描述故障现象,以便我们更准确快速的为您解决问题"></textarea>
  56. </view>
  57. </view>
  58. <!-- 底部 -->
  59. <view class="bottom">
  60. <button class="submit" @click="submit">提交工单</button>
  61. </view>
  62. </view>
  63. </template>
  64. <script>
  65. import * as API from '@/apis/pagejs/energy/index.js'
  66. import * as API_workOrder from '@/apis/pagejs/energy/workOrder.js'
  67. export default {
  68. data() {
  69. return {
  70. stateIndex: -1,
  71. stateList: [], //故障类型List
  72. faultForm: {
  73. deviceId: '', //故障设备id
  74. deviceName: '',
  75. faultType: '', //故障类型
  76. pic: '', //故障拍照
  77. content: '' //故障内容
  78. },
  79. show: false,
  80. deviceList: [], //设备
  81. action: '',
  82. fileList: [],
  83. formData: {}
  84. }
  85. },
  86. onLoad() {
  87. this.action = process.car.BASE_URL + "uploadFile";
  88. this.formData = {
  89. subFolder: "workorder"
  90. }
  91. var token = this.carhelp.getToken();
  92. this.header={
  93. 'Authorization': token,
  94. 'X-Requested-With': 'application/x-www-form-urlencoded'
  95. }
  96. this.getLoadMyDevices();
  97. this.getFindByCatalogName();
  98. },
  99. methods: {
  100. submit() {
  101. let files = [];
  102. // 通过filter,筛选出上传进度为100的文件(因为某些上传失败的文件,进度值不为100,这个是可选的操作)
  103. files = this.$refs.uUpload.lists.filter(val => {
  104. return val.progress == 100;
  105. })
  106. // 如果您不需要进行太多的处理,直接如下即可
  107. files = this.$refs.uUpload.lists;
  108. var imgUrl = files.map(item => {
  109. return item.response.data.url;
  110. })
  111. this.faultForm.pic = imgUrl.join(',');
  112. if(!this.faultForm.deviceId){
  113. uni.showToast({
  114. icon: "none",
  115. title: "请选择故障设备"
  116. })
  117. return
  118. }
  119. if(!this.faultForm.faultType){
  120. uni.showToast({
  121. icon: "none",
  122. title: "请选择故障类型"
  123. })
  124. return
  125. }
  126. uni.showLoading({
  127. title: "加载中",
  128. mask: true,
  129. })
  130. API_workOrder.usCreate(this.faultForm).then((res) => {
  131. uni.hideLoading();
  132. uni.navigateTo({
  133. url: '/pages/workOrderManagement/workOrderManagement'
  134. })
  135. }).catch(error => {
  136. uni.showToast({
  137. title: error,
  138. icon: "none"
  139. })
  140. })
  141. },
  142. //选择故障类型
  143. stateClick(item,index) {
  144. this.stateIndex = index;
  145. this.faultForm.faultType = item.value;
  146. },
  147. // 异常查询条件
  148. getFindByCatalogName() {
  149. uni.showLoading({
  150. title: "加载中",
  151. mask: true,
  152. })
  153. API_workOrder.findByCatalogName({
  154. catalogName: '故障类型'
  155. }).then((response) => {
  156. uni.hideLoading();
  157. var list = response.data.map(item => {
  158. return {
  159. label: item.name,
  160. value: item.id
  161. }
  162. });
  163. this.stateList = list;
  164. }).catch(error => {
  165. uni.showToast({
  166. title: error,
  167. icon: "none"
  168. })
  169. })
  170. },
  171. //选择设备
  172. deviceConfirm(e) {
  173. console.log(e)
  174. this.faultForm.deviceId = e[0].value;
  175. this.faultForm.deviceName = e[0].label;
  176. },
  177. getLoadMyDevices() {
  178. uni.showLoading({
  179. title: "加载中",
  180. mask: true,
  181. })
  182. API_workOrder.loadMyDevices().then((response) => {
  183. uni.hideLoading();
  184. this.deviceList = [];
  185. this.deviceList = response.data.map(item => {
  186. return {
  187. label: item.name,
  188. value: item.id
  189. }
  190. });
  191. }).catch(error => {
  192. uni.showToast({
  193. title: error,
  194. icon: "none"
  195. })
  196. })
  197. },
  198. }
  199. }
  200. </script>
  201. <style lang="scss" scoped>
  202. /deep/.u-select__header__title {
  203. font-size: 36rpx;
  204. font-weight: bold;
  205. }
  206. .main {
  207. background-color: #fff;
  208. // 故障设备
  209. .fault-equipment {
  210. display: flex;
  211. align-items: center;
  212. padding: 24rpx 32rpx;
  213. border-bottom: 1px solid rgba(221, 221, 221, 1);
  214. .title {
  215. font-size: 32rpx;
  216. color: #777777;
  217. width: 144rpx;
  218. .asterisk {
  219. color: rgba(238, 49, 56, 1);
  220. }
  221. }
  222. .value {
  223. display: flex;
  224. align-items: center;
  225. justify-content: space-between;
  226. margin-left: 64rpx;
  227. flex: 1;
  228. .placeholder {
  229. color: rgba(172, 172, 172, 1);
  230. font-size: 32rpx;
  231. }
  232. }
  233. }
  234. // 故障类型
  235. .fault-type {
  236. .title {
  237. font-size: 32rpx;
  238. color: #111111;
  239. padding: 32rpx 32rpx 0;
  240. font-weight: bold;
  241. .asterisk {
  242. color: rgba(238, 49, 56, 1);
  243. }
  244. }
  245. .type {
  246. display: flex;
  247. padding: 24rpx 32rpx;
  248. align-items: center;
  249. flex-wrap: wrap;
  250. .type-item {
  251. border: 1px solid rgba(216, 223, 232, 1);
  252. color: rgba(16, 16, 16, 1);
  253. line-height: 66rpx;
  254. text-align: center;
  255. border-radius: 4px;
  256. padding:0 16rpx;
  257. line-height: 66rpx;
  258. margin-right: 16rpx;
  259. margin-bottom: 16rpx;
  260. }
  261. .item-checked {
  262. background-color: rgba(22, 119, 255, 1);
  263. color: rgba(255, 255, 255, 1);
  264. }
  265. }
  266. }
  267. }
  268. // 照片上传 故障描述
  269. .picture-upload,
  270. .fault-description {
  271. padding: 32rpx 32rpx;
  272. background-color: #fff;
  273. margin-top: 24rpx;
  274. .title {
  275. color: rgb(16, 16, 16);
  276. font-size: 32rpx;
  277. margin-bottom: 24rpx;
  278. font-weight: bold;
  279. }
  280. .textarea {
  281. /deep/.uni-textarea-placeholder {
  282. color: #b2b2b2;
  283. }
  284. /deep/uni-textarea {
  285. width: 660rpx;
  286. height: 180rpx;
  287. }
  288. }
  289. }
  290. // 底部
  291. .bottom {
  292. padding: 20rpx 32rpx;
  293. background-color: #fff;
  294. position: fixed;
  295. left: 0;
  296. right: 0;
  297. bottom: 0;
  298. .submit {
  299. border-radius: 4px;
  300. background-color: rgba(22, 119, 255, 1);
  301. color: rgba(255, 255, 255, 1);
  302. font-size: 32rpx;
  303. line-height: 80rpx;
  304. }
  305. }
  306. </style>