securityCheck.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  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. 'customerImg': {
  106. type: 'string',
  107. required: true,
  108. message: '请上传客户签名',
  109. trigger: ['blur', 'change']
  110. },
  111. 'signImg': {
  112. type: 'string',
  113. required: true,
  114. message: '请上传送气员签名',
  115. trigger: ['blur', 'change']
  116. },
  117. },
  118. }
  119. },
  120. onLoad(e) {
  121. this.ruleForm.orderId = e.orderId
  122. this.ruleForm.customerId = e.customerId
  123. //注册监听事件
  124. uni.$on('sign', (data) => {
  125. //base64编码的图片
  126. if (this.personnelType == 'client') {
  127. this.clientFlag = false
  128. this.imageData = data.replace(/[\r\n]/g, "");
  129. this.getUpload(data)
  130. } else {
  131. this.aeratorFlag = false
  132. this.aeratorData = data.replace(/[\r\n]/g, "");
  133. this.getUpload(data)
  134. }
  135. //处理自己的业务逻辑
  136. })
  137. },
  138. //销毁监听事件
  139. onUnload() {
  140. uni.$off('sign');
  141. },
  142. mounted() {
  143. this.getCheck()
  144. // this.checkEntry = check()
  145. },
  146. methods: {
  147. // 获取入户安全检查项
  148. getCheck() {
  149. this.$api.get('/api/inspect-expand', {
  150. pageSize: 9999,
  151. }).then(res => {
  152. if (res.code == 200) {
  153. this.checkEntry = res.data.list
  154. this.checkEntry.forEach(item => {
  155. item.value = '0'
  156. })
  157. }
  158. })
  159. },
  160. // 提价入户安全检查项
  161. entrySecurity() {
  162. this.$refs.uForm.validate().then(res => {
  163. const param = {
  164. ...this.ruleForm
  165. }
  166. const arrList = []
  167. this.checkEntry.forEach(item => {
  168. const arr1 = {
  169. inspectItem: '',
  170. itemCode: '',
  171. }
  172. arr1.inspectItem = item.inspectItem
  173. arr1.itemCode = item.value
  174. arrList.push(arr1)
  175. })
  176. param.inspectExpandList = arrList
  177. uni.showLoading({
  178. mask: true,
  179. });
  180. this.$api.post('/api/inspect_record', param).then(res => {
  181. if (res.code == 200) {
  182. uni.hideLoading();
  183. uni.$u.toast('操作成功')
  184. setTimeout(() => {
  185. uni.$emit('refresh');
  186. uni.navigateBack({
  187. delta: 1
  188. });
  189. }, 1000)
  190. } else {
  191. uni.hideLoading();
  192. uni.$u.toast(res.data.msg)
  193. }
  194. }).catch(() => {
  195. uni.hideLoading();
  196. })
  197. }).catch(errors => {
  198. // uni.$u.toast('校验失败')
  199. })
  200. },
  201. // 删除图片
  202. deletePic(event) {
  203. this[`fileList${event.name}`].splice(event.index, 1)
  204. },
  205. // 签名板
  206. async getUpload(file) {
  207. const result = await this.uploadFilePromise(file)
  208. if (this.personnelType == 'client') {
  209. this.ruleForm.customerImg = result
  210. if (this.$refs.uForm) {
  211. this.$refs.uForm.validateField('customerImg')
  212. }
  213. } else {
  214. this.ruleForm.signImg = result
  215. if (this.$refs.uForm) {
  216. this.$refs.uForm.validateField('signImg')
  217. }
  218. }
  219. },
  220. // 新增图片
  221. async afterRead(event) {
  222. uni.showLoading({
  223. mask: true,
  224. });
  225. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  226. let lists = [].concat(event.file)
  227. let fileListLen = this[`fileList${event.name}`].length
  228. lists.map((item) => {
  229. this[`fileList${event.name}`].push({
  230. ...item,
  231. status: 'uploading',
  232. message: '上传中'
  233. })
  234. })
  235. for (let i = 0; i < lists.length; i++) {
  236. const result = await this.uploadFilePromise(lists[i].url)
  237. let item = this[`fileList${event.name}`][fileListLen]
  238. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  239. status: 'success',
  240. message: '',
  241. url: result
  242. }))
  243. fileListLen++
  244. }
  245. if (event.name == '1') {
  246. var arr = []
  247. this.fileList1.forEach(item1 => {
  248. arr.push(item1.url)
  249. })
  250. this.ruleForm.homeCheckImg = arr.join()
  251. this.$refs.uForm.validateField('homeCheckImg')
  252. } else {
  253. var arr1 = []
  254. this.fileList2.forEach(item2 => {
  255. arr.push(item2.url)
  256. })
  257. this.ruleForm.beforeRectifyImg = arr1.join()
  258. this.$refs.uForm.validateField('beforeRectifyImg')
  259. }
  260. uni.hideLoading();
  261. },
  262. uploadFilePromise(url) {
  263. return new Promise((resolve, reject) => {
  264. let a = uni.uploadFile({
  265. url: ENV.APP_DEV_URL + '/api/upload', // 仅为示例,非真实的接口地址
  266. filePath: url,
  267. name: 'file',
  268. // formData: {
  269. // user: 'test'
  270. // },
  271. header: {
  272. 'Authorization': 'Bearer ' + uni.getStorageSync('access_token'),
  273. },
  274. success: (res) => {
  275. let state = JSON.parse(res.data)
  276. if (state.code == 200) {
  277. resolve(state.data)
  278. }
  279. }
  280. });
  281. })
  282. },
  283. // 签字
  284. goSignature(title) {
  285. this.personnelType = title
  286. uni.navigateTo({
  287. url: '/pages/order/signatureBoard'
  288. });
  289. },
  290. }
  291. }
  292. </script>
  293. <style lang="scss" scoped>
  294. .card_order_details {
  295. margin: 20rpx 40rpx;
  296. }
  297. .card_plate {
  298. margin-top: 20rpx;
  299. margin-bottom: 40rpx;
  300. }
  301. .details_title {
  302. color: #333;
  303. font-size: 40rpx;
  304. font-weight: 500;
  305. }
  306. .card_check {
  307. font-size: 34rpx;
  308. font-weight: 500;
  309. margin-bottom: 20rpx;
  310. }
  311. .title_item_check {
  312. margin-top: 30rpx;
  313. font-size: 30rpx;
  314. margin-bottom: 15rpx;
  315. }
  316. .check_btn {
  317. position: fixed;
  318. display: flex;
  319. align-items: center;
  320. justify-content: center;
  321. left: 0;
  322. right: 0;
  323. bottom: 0;
  324. background-color: #fff;
  325. border-top: 1rpx solid #f7f7f7;
  326. padding-bottom: constant(safe-area-inset-bottom); //兼容 IOS<11.2
  327. padding-bottom: env(safe-area-inset-bottom); //兼容 IOS>11.2
  328. }
  329. .btn_submit {
  330. margin-top: 10rpx;
  331. padding-bottom: 20rpx;
  332. width: calc(100% - 80rpx);
  333. }
  334. .card_signs {
  335. width: 200rpx;
  336. height: 160rpx;
  337. background-color: #f4f5f7;
  338. color: #d3d4d6;
  339. font-size: 32rpx;
  340. border-radius: 4rpx;
  341. }
  342. </style>