securityCheck.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  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: result
  248. }))
  249. fileListLen++
  250. }
  251. if (event.name == '1') {
  252. var arr = []
  253. this.fileList1.forEach(item1 => {
  254. arr.push(item1.url)
  255. })
  256. this.ruleForm.homeCheckImg = arr.join()
  257. this.$refs.uForm.validateField('homeCheckImg')
  258. } else {
  259. var arr1 = []
  260. this.fileList2.forEach(item2 => {
  261. arr1.push(item2.url)
  262. })
  263. this.ruleForm.beforeRectifyImg = arr1.join()
  264. this.$refs.uForm.validateField('beforeRectifyImg')
  265. }
  266. uni.hideLoading();
  267. },
  268. uploadFilePromise(url) {
  269. return new Promise((resolve, reject) => {
  270. let a = uni.uploadFile({
  271. url: ENV.APP_DEV_URL + '/api/upload', // 仅为示例,非真实的接口地址
  272. filePath: url,
  273. name: 'file',
  274. // formData: {
  275. // user: 'test'
  276. // },
  277. header: {
  278. 'Authorization': 'Bearer ' + uni.getStorageSync('access_token'),
  279. },
  280. success: (res) => {
  281. let state = JSON.parse(res.data)
  282. if (state.code == 200) {
  283. resolve(state.data)
  284. }
  285. }
  286. });
  287. })
  288. },
  289. // 签字
  290. goSignature(title) {
  291. this.personnelType = title
  292. uni.navigateTo({
  293. url: '/pages/order/signatureBoard'
  294. });
  295. },
  296. }
  297. }
  298. </script>
  299. <style lang="scss" scoped>
  300. .card_order_details {
  301. margin: 20rpx 40rpx;
  302. }
  303. .card_plate {
  304. margin-top: 20rpx;
  305. margin-bottom: 40rpx;
  306. }
  307. .details_title {
  308. color: #333;
  309. font-size: 40rpx;
  310. font-weight: 500;
  311. }
  312. .card_check {
  313. font-size: 34rpx;
  314. font-weight: 500;
  315. margin-bottom: 20rpx;
  316. }
  317. .title_item_check {
  318. margin-top: 30rpx;
  319. font-size: 30rpx;
  320. margin-bottom: 15rpx;
  321. }
  322. .check_btn {
  323. position: fixed;
  324. display: flex;
  325. align-items: center;
  326. justify-content: center;
  327. left: 0;
  328. right: 0;
  329. bottom: 0;
  330. background-color: #fff;
  331. border-top: 1rpx solid #f7f7f7;
  332. padding-bottom: constant(safe-area-inset-bottom); //兼容 IOS<11.2
  333. padding-bottom: env(safe-area-inset-bottom); //兼容 IOS>11.2
  334. }
  335. .btn_submit {
  336. margin-top: 10rpx;
  337. padding-bottom: 20rpx;
  338. width: calc(100% - 80rpx);
  339. }
  340. .card_signs {
  341. width: 200rpx;
  342. height: 160rpx;
  343. background-color: #f4f5f7;
  344. color: #d3d4d6;
  345. font-size: 32rpx;
  346. border-radius: 4rpx;
  347. }
  348. </style>