faultReport.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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/index.js'
  66. import * as API_workOrder from '@/apis/pagejs/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. if(!this.faultForm.content){
  127. uni.showToast({
  128. icon: "none",
  129. title: "请填写故障描述"
  130. })
  131. return
  132. }
  133. uni.showLoading({
  134. title: "加载中",
  135. mask: true,
  136. })
  137. API_workOrder.usCreate(this.faultForm).then((res) => {
  138. uni.hideLoading();
  139. uni.navigateTo({
  140. url: '/pages/workOrderManagement/workOrderManagement'
  141. })
  142. }).catch(error => {
  143. uni.showToast({
  144. title: error,
  145. icon: "none"
  146. })
  147. })
  148. },
  149. //选择故障类型
  150. stateClick(item,index) {
  151. this.stateIndex = index;
  152. this.faultForm.faultType = item.value;
  153. },
  154. // 异常查询条件
  155. getFindByCatalogName() {
  156. uni.showLoading({
  157. title: "加载中",
  158. mask: true,
  159. })
  160. API_workOrder.findByCatalogName({
  161. catalogName: '故障类型'
  162. }).then((response) => {
  163. uni.hideLoading();
  164. var list = response.data.map(item => {
  165. return {
  166. label: item.name,
  167. value: item.id
  168. }
  169. });
  170. this.stateList = list;
  171. }).catch(error => {
  172. uni.showToast({
  173. title: error,
  174. icon: "none"
  175. })
  176. })
  177. },
  178. //选择设备
  179. deviceConfirm(e) {
  180. console.log(e)
  181. this.faultForm.deviceId = e[0].value;
  182. this.faultForm.deviceName = e[0].label;
  183. },
  184. getLoadMyDevices() {
  185. uni.showLoading({
  186. title: "加载中",
  187. mask: true,
  188. })
  189. API_workOrder.loadMyDevices().then((response) => {
  190. uni.hideLoading();
  191. this.deviceList = [];
  192. this.deviceList = response.data.map(item => {
  193. return {
  194. label: item.name,
  195. value: item.id
  196. }
  197. });
  198. }).catch(error => {
  199. uni.showToast({
  200. title: error,
  201. icon: "none"
  202. })
  203. })
  204. },
  205. }
  206. }
  207. </script>
  208. <style lang="scss" scoped>
  209. ::v-deep.u-select__header__title {
  210. font-size: 36rpx;
  211. font-weight: bold;
  212. }
  213. .main {
  214. background-color: #fff;
  215. // 故障设备
  216. .fault-equipment {
  217. display: flex;
  218. align-items: center;
  219. padding: 24rpx 32rpx;
  220. border-bottom: 1px solid rgba(221, 221, 221, 1);
  221. .title {
  222. font-size: 32rpx;
  223. color: #777777;
  224. width: 144rpx;
  225. .asterisk {
  226. color: rgba(238, 49, 56, 1);
  227. }
  228. }
  229. .value {
  230. display: flex;
  231. align-items: center;
  232. justify-content: space-between;
  233. margin-left: 64rpx;
  234. flex: 1;
  235. .placeholder {
  236. color: rgba(172, 172, 172, 1);
  237. font-size: 32rpx;
  238. }
  239. }
  240. }
  241. // 故障类型
  242. .fault-type {
  243. .title {
  244. font-size: 32rpx;
  245. color: #111111;
  246. padding: 32rpx 32rpx 0;
  247. font-weight: bold;
  248. .asterisk {
  249. color: rgba(238, 49, 56, 1);
  250. }
  251. }
  252. .type {
  253. display: flex;
  254. padding: 24rpx 32rpx;
  255. align-items: center;
  256. flex-wrap: wrap;
  257. .type-item {
  258. border: 1px solid rgba(216, 223, 232, 1);
  259. color: rgba(16, 16, 16, 1);
  260. line-height: 66rpx;
  261. text-align: center;
  262. border-radius: 4px;
  263. padding:0 16rpx;
  264. line-height: 66rpx;
  265. margin-right: 16rpx;
  266. margin-bottom: 16rpx;
  267. }
  268. .item-checked {
  269. background-color: rgba(22, 119, 255, 1);
  270. color: rgba(255, 255, 255, 1);
  271. }
  272. }
  273. }
  274. }
  275. // 照片上传 故障描述
  276. .picture-upload,
  277. .fault-description {
  278. padding: 32rpx 32rpx;
  279. background-color: #fff;
  280. margin-top: 24rpx;
  281. .title {
  282. color: rgb(16, 16, 16);
  283. font-size: 32rpx;
  284. margin-bottom: 24rpx;
  285. font-weight: bold;
  286. }
  287. .textarea {
  288. ::v-deep.uni-textarea-placeholder {
  289. color: #b2b2b2;
  290. }
  291. ::v-deepuni-textarea {
  292. width: 660rpx;
  293. height: 180rpx;
  294. }
  295. }
  296. }
  297. // 底部
  298. .bottom {
  299. padding: 20rpx 32rpx;
  300. background-color: #fff;
  301. position: fixed;
  302. left: 0;
  303. right: 0;
  304. bottom: 0;
  305. .submit {
  306. border-radius: 4px;
  307. background-color: rgba(22, 119, 255, 1);
  308. color: rgba(255, 255, 255, 1);
  309. font-size: 32rpx;
  310. line-height: 80rpx;
  311. }
  312. }
  313. </style>