securityCheck.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. <template>
  2. <!-- 入户安全检查 -->
  3. <view>
  4. <u-navbar title="入户安全检查" autoBack placeholder></u-navbar>
  5. <view class="card_order_details">
  6. <u-form labelPosition="top" :model="ruleForm" :rules="rules" ref="uForm" labelWidth="auto">
  7. <u-form-item label="入户检查图片" prop="homeCheckImg">
  8. <u-upload :fileList="fileList1" name="1" multiple :maxCount="10" @afterRead="afterRead"
  9. @delete="deletePic"></u-upload>
  10. </u-form-item>
  11. <u-form-item label="状态" prop="state">
  12. <u-radio-group v-model="ruleForm.state" placement="row">
  13. <u-radio shape="circle" :customStyle="{marginRight: '20px'}" v-for="(item, index) in radiolist"
  14. :key="index" :label="item.name" :name="item.value"></u-radio>
  15. </u-radio-group>
  16. </u-form-item>
  17. <u-form-item label="整改前照片" prop="beforeRectifyImg" v-if="ruleForm.state == 0">
  18. <u-upload :fileList="fileList2" name="2" multiple :maxCount="10" @afterRead="afterRead"
  19. @delete="deletePic"></u-upload>
  20. </u-form-item>
  21. <u-form-item label="客户签字" prop="customerImg">
  22. <view class="card_signs center_in" v-if="clientFlag" @click="goSignature('client')">客户签字</view>
  23. <u-image :showLoading="true" :src="imageData" width="200rpx" height="160rpx"
  24. @click="goSignature('client')" v-else></u-image>
  25. </u-form-item>
  26. <u-form-item label="送气员签字" prop="signImg">
  27. <view class="card_signs center_in" v-if="aeratorFlag" @click="goSignature('aerator')">送气员签字</view>
  28. <u-image :showLoading="true" :src="aeratorData" width="200rpx" height="160rpx"
  29. @click="goSignature('aerator')" v-else></u-image>
  30. </u-form-item>
  31. </u-form>
  32. <view class="card_plate">
  33. <view class="card_check">安全检查项目<span style="color: red;">*</span></view>
  34. <u-line></u-line>
  35. <view class="card_security">
  36. <view class="" v-for="(item,index) in checkEntry" :key="index">
  37. <view class="title_item_check">{{index + 1}}、{{item.inspectExplain}}</view>
  38. <u-radio-group v-model="item.value" placement="row">
  39. <u-radio shape="circle" :customStyle="{marginRight: '20px'}"
  40. v-for="(item1, index1) in radioData" :key="index1" :label="item1.name"
  41. :name="item1.value"></u-radio>
  42. </u-radio-group>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. <view style="width: 100%;height: 170rpx;"></view>
  48. <view class="check_btn">
  49. <view class="btn_submit">
  50. <u-button type="primary" text="提交" @click="entrySecurity"></u-button>
  51. </view>
  52. </view>
  53. </view>
  54. </template>
  55. <script>
  56. const ENV = require('@/.env.js')
  57. import {
  58. check
  59. } from '@/static/js/announcements.js'
  60. export default {
  61. data() {
  62. return {
  63. fileList1: [],
  64. fileList2: [],
  65. radiolist: [{
  66. name: '合格',
  67. value: -1,
  68. disabled: false
  69. }, {
  70. name: '待整改',
  71. value: 0,
  72. disabled: false
  73. }],
  74. radioData: [{
  75. name: '合格',
  76. value: '0',
  77. disabled: false
  78. }, {
  79. name: '待整改',
  80. value: '1',
  81. disabled: false
  82. }],
  83. checkEntry: [],
  84. clientFlag: true,
  85. aeratorFlag: true,
  86. personnelType: '',
  87. imageData: '',
  88. aeratorData: '',
  89. ruleForm: {
  90. orderId: '',
  91. customerId: '',
  92. homeCheckImg: '',
  93. customerImg: '',
  94. signImg: '',
  95. state: -1,
  96. inspectExpandList: [],
  97. },
  98. rules: {
  99. 'homeCheckImg': {
  100. type: 'string',
  101. required: true,
  102. message: '请上传入户检查图片',
  103. trigger: ['blur', 'change']
  104. },
  105. 'beforeRectifyImg': {
  106. type: 'string',
  107. required: true,
  108. message: '请上传整改前照片',
  109. trigger: ['blur', 'change']
  110. },
  111. 'customerImg': {
  112. type: 'string',
  113. required: true,
  114. message: '请上传客户签名',
  115. trigger: ['blur', 'change']
  116. },
  117. 'signImg': {
  118. type: 'string',
  119. required: true,
  120. message: '请上传送气员签名',
  121. trigger: ['blur', 'change']
  122. },
  123. },
  124. }
  125. },
  126. onLoad(e) {
  127. this.ruleForm.orderId = e.orderId
  128. this.ruleForm.customerId = e.customerId
  129. //注册监听事件
  130. uni.$on('sign', (data) => {
  131. //base64编码的图片
  132. if (this.personnelType == 'client') {
  133. this.clientFlag = false
  134. this.imageData = data.replace(/[\r\n]/g, "");
  135. this.getUpload(data)
  136. } else {
  137. this.aeratorFlag = false
  138. this.aeratorData = data.replace(/[\r\n]/g, "");
  139. this.getUpload(data)
  140. }
  141. //处理自己的业务逻辑
  142. })
  143. },
  144. //销毁监听事件
  145. onUnload() {
  146. uni.$off('sign');
  147. },
  148. mounted() {
  149. this.getCheck()
  150. // this.checkEntry = check()
  151. },
  152. methods: {
  153. // 获取入户安全检查项
  154. getCheck() {
  155. this.$api.get('/api/inspect-expand', {
  156. pageSize: 9999,
  157. }).then(res => {
  158. if (res.code == 200) {
  159. this.checkEntry = res.data.list
  160. this.checkEntry.forEach(item => {
  161. item.value = '0'
  162. })
  163. }
  164. })
  165. },
  166. // 提价入户安全检查项
  167. entrySecurity() {
  168. this.$refs.uForm.validate().then(res => {
  169. const param = {
  170. ...this.ruleForm
  171. }
  172. const arrList = []
  173. this.checkEntry.forEach(item => {
  174. const arr1 = {
  175. inspectItem: '',
  176. itemCode: '',
  177. }
  178. arr1.inspectItem = item.inspectItem
  179. arr1.itemCode = item.value
  180. arrList.push(arr1)
  181. })
  182. param.inspectExpandList = arrList
  183. uni.showLoading({
  184. mask: true,
  185. });
  186. this.$api.post('/api/inspect_record', param).then(res => {
  187. if (res.code == 200) {
  188. uni.hideLoading();
  189. uni.$u.toast('操作成功')
  190. setTimeout(() => {
  191. uni.$emit('refresh');
  192. uni.navigateBack({
  193. delta: 1
  194. });
  195. }, 1000)
  196. } else {
  197. uni.hideLoading();
  198. uni.$u.toast(res.data.msg)
  199. }
  200. }).catch(() => {
  201. uni.hideLoading();
  202. })
  203. }).catch(errors => {
  204. // uni.$u.toast('校验失败')
  205. })
  206. },
  207. // 删除图片
  208. deletePic(event) {
  209. this[`fileList${event.name}`].splice(event.index, 1)
  210. },
  211. // 签名板
  212. async getUpload(file) {
  213. const result = await this.uploadFilePromise(file)
  214. if (this.personnelType == 'client') {
  215. this.ruleForm.customerImg = result
  216. if (this.$refs.uForm) {
  217. this.$refs.uForm.validateField('customerImg')
  218. }
  219. } else {
  220. this.ruleForm.signImg = result
  221. if (this.$refs.uForm) {
  222. this.$refs.uForm.validateField('signImg')
  223. }
  224. }
  225. },
  226. // 新增图片
  227. async afterRead(event) {
  228. uni.showLoading({
  229. mask: true,
  230. });
  231. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  232. let lists = [].concat(event.file)
  233. let fileListLen = this[`fileList${event.name}`].length
  234. lists.map((item) => {
  235. this[`fileList${event.name}`].push({
  236. ...item,
  237. status: 'uploading',
  238. message: '上传中'
  239. })
  240. })
  241. for (let i = 0; i < lists.length; i++) {
  242. const result = await this.uploadFilePromise(lists[i].url)
  243. let item = this[`fileList${event.name}`][fileListLen]
  244. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  245. status: 'success',
  246. message: '',
  247. url: this.$baseUrl + result
  248. }))
  249. fileListLen++
  250. }
  251. uni.hideLoading();
  252. if (event.name == '1') {
  253. var arr = []
  254. this.fileList1.forEach(item1 => {
  255. let img = item1.url.split(this.$baseUrl)
  256. arr.push(img[1])
  257. })
  258. this.ruleForm.homeCheckImg = arr.join()
  259. this.$refs.uForm.validateField('homeCheckImg')
  260. } else {
  261. var arr1 = []
  262. this.fileList2.forEach(item2 => {
  263. <<<<<<< HEAD
  264. arr1.push(item2.url)
  265. =======
  266. let img1 = item2.url.split(this.$baseUrl)
  267. arr1.push(img1[1])
  268. >>>>>>> ec9bba9783fc5bf29c8b3276224b1ab4fab155dc
  269. })
  270. this.ruleForm.beforeRectifyImg = arr1.join()
  271. this.$refs.uForm.validateField('beforeRectifyImg')
  272. }
  273. uni.hideLoading();
  274. },
  275. uploadFilePromise(url) {
  276. return new Promise((resolve, reject) => {
  277. let a = uni.uploadFile({
  278. url: ENV.APP_DEV_URL + '/api/upload', // 仅为示例,非真实的接口地址
  279. filePath: url,
  280. name: 'file',
  281. // formData: {
  282. // user: 'test'
  283. // },
  284. header: {
  285. 'Authorization': 'Bearer ' + uni.getStorageSync('access_token'),
  286. },
  287. success: (res) => {
  288. let state = JSON.parse(res.data)
  289. if (state.code == 200) {
  290. resolve(state.data)
  291. }
  292. }
  293. });
  294. })
  295. },
  296. // 签字
  297. goSignature(title) {
  298. this.personnelType = title
  299. uni.navigateTo({
  300. url: '/pages/order/signatureBoard'
  301. });
  302. },
  303. }
  304. }
  305. </script>
  306. <style lang="scss" scoped>
  307. .card_order_details {
  308. margin: 20rpx 40rpx;
  309. }
  310. .card_plate {
  311. margin-top: 20rpx;
  312. margin-bottom: 40rpx;
  313. }
  314. .details_title {
  315. color: #333;
  316. font-size: 40rpx;
  317. font-weight: 500;
  318. }
  319. .card_check {
  320. font-size: 34rpx;
  321. font-weight: 500;
  322. margin-bottom: 20rpx;
  323. }
  324. .title_item_check {
  325. margin-top: 30rpx;
  326. font-size: 30rpx;
  327. margin-bottom: 15rpx;
  328. }
  329. .check_btn {
  330. position: fixed;
  331. display: flex;
  332. align-items: center;
  333. justify-content: center;
  334. left: 0;
  335. right: 0;
  336. bottom: 0;
  337. background-color: #fff;
  338. border-top: 1rpx solid #f7f7f7;
  339. padding-bottom: constant(safe-area-inset-bottom); //兼容 IOS<11.2
  340. padding-bottom: env(safe-area-inset-bottom); //兼容 IOS>11.2
  341. }
  342. .btn_submit {
  343. margin-top: 10rpx;
  344. padding-bottom: 20rpx;
  345. width: calc(100% - 80rpx);
  346. }
  347. .card_signs {
  348. width: 200rpx;
  349. height: 160rpx;
  350. background-color: #f4f5f7;
  351. color: #d3d4d6;
  352. font-size: 32rpx;
  353. border-radius: 4rpx;
  354. }
  355. </style>