edit_archive4.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. <template>
  2. <view class=" uni-container">
  3. <view class="example container" :style="'height: ' + (screenHeight - wheight - 75) + 'px'">
  4. <!-- 自定义表单校验 1-->
  5. <u--form ref="customForm" :model="formData" labelPosition="left" labelWidth="300" labelAlign="left">
  6. <view class=" flex flex-direction width100">
  7. <u-form-item label="地点" prop="dd" :required="true">
  8. <u-input v-model="formData.dd" placeholder="必填。请输入地点" />
  9. </u-form-item>
  10. <u-form-item label="起火时间" prop="qhsj" :required="true">
  11. <uni-datetime-picker :show="unitTime" v-model="formData.qhsj" mode="date" closeOnClickOverlay
  12. @confirm="ActiveUnitTime" @cancel="unitTime = false"
  13. @close="unitTime = false"></uni-datetime-picker>
  14. </u-form-item>
  15. <u-form-item label="事故原因" prop="sgyy" :required="true">
  16. <u-input v-model="formData.sgyy" placeholder="事故原因" />
  17. </u-form-item>
  18. <u-form-item label="财产损失金额" :required="true">
  19. <u-input v-model="formData.ccssje" placeholder="请输入财产损失金额" />
  20. </u-form-item>
  21. <u-form-item label="调查单位 "><u-input v-model="formData.dcdw" placeholder="请输入调查单位" /></u-form-item>
  22. <u-form-item label="人员伤亡情况 ">
  23. <u-input v-model="formData.ryswqk" placeholder="请输入人员伤亡情况" />
  24. </u-form-item>
  25. <u-form-item label="过火面积"><u-input v-model="formData.ghmj" placeholder="是否过火面积" /></u-form-item>
  26. <!-- <u-form-item label="*所属乡镇街道" @click="hideKeyboard()" prop="streetName">
  27. <u--input
  28. v-model="formData.streetName"
  29. disabled
  30. disabledColor="#ffffff"
  31. placeholder="请选择所属乡镇街道"
  32. ></u--input>
  33. </u-form-item> -->
  34. <u-form-item label="受灾户数"><u-input v-model="formData.szhs" placeholder="受灾户数" /></u-form-item>
  35. <u-form-item label="备注">
  36. <u-textarea auto-height maxlength="-1" v-model="formData.remark"
  37. placeholder="请输入备注"></u-textarea>
  38. </u-form-item>
  39. </view>
  40. </u--form>
  41. </view>
  42. <uni-row class="heigthButton">
  43. <u-button @click="submit('customForm')" type="primary" shape="circle" size="large" color="#4CB2B6"
  44. text="确认修改"></u-button>
  45. </uni-row>
  46. </view>
  47. </template>
  48. <script>
  49. import {
  50. updateArchive, // 更新
  51. getDepartment //获取登陆人的部门信息
  52. } from '@/api/archive/index4.js';
  53. var that = null;
  54. export default {
  55. data() {
  56. return {
  57. screenHeight: this.$screenHeight,
  58. wheight: '',
  59. // 每页数据量
  60. pageSize: 5,
  61. // 当前页
  62. pageNo: 1,
  63. // 数据总量
  64. total: 0,
  65. unitTime: false,
  66. loading: false,
  67. title: '生成隐患',
  68. content: '确认将此检查项目生成为隐患',
  69. // 自定义表单数据
  70. formData: {
  71. status: '0'
  72. },
  73. // 自定义表单校验规则
  74. customRules: {
  75. dd: {
  76. type: 'string',
  77. required: true,
  78. message: '地点不能为空',
  79. trigger: ['blur', 'change']
  80. },
  81. sgyy: {
  82. type: 'string',
  83. required: true,
  84. message: '事故原因不能为空',
  85. trigger: ['blur', 'change']
  86. },
  87. qhsj: {
  88. type: 'string',
  89. required: true,
  90. message: '起火时间不能为空',
  91. trigger: ['blur', 'change']
  92. }
  93. }
  94. };
  95. },
  96. computed: {},
  97. mounted() {
  98. uni.createSelectorQuery().in(this).select('.heigthButton').boundingClientRect(data => {
  99. this.wheight = data.height
  100. }).exec()
  101. },
  102. onLoad: function(option) {
  103. that = this
  104. var data = option.id;
  105. // 接收来自上个页面传递的参数
  106. const eventChannel = this.getOpenerEventChannel();
  107. eventChannel.on('acceptDataFromOpenerPage', function(val) {
  108. that.formData = val;
  109. });
  110. // 以下内容都是为了 选择街道
  111. const deptValue = uni.getStorageSync('getDepartment_key'); //所有街道
  112. const deptId = uni.getStorageSync('getUserInfo_key').streetInfo.id; //登录用户的街道id
  113. var newArrar = {}; //新对象
  114. // 如果存在街道id,就直接取出对应的名称
  115. if (deptId) {
  116. newArrar = deptValue.find((item) => {
  117. if (item.id === deptId) {
  118. this.formData.streetId = item.id;
  119. this.formData.streetName = item.name;
  120. }
  121. })
  122. }
  123. },
  124. onReady() {
  125. this.$refs.customForm.setRules(this.customRules);
  126. },
  127. methods: {
  128. submit(ref) {
  129. this.$refs[ref]
  130. .validate()
  131. .then(res => {
  132. this.formData['status'] = 0;
  133. var jsdata = JSON.stringify(this.formData);
  134. console.log(jsdata, 'jsdatajsdatajsdata');
  135. updateArchive(jsdata).then(response => {
  136. console.log('response.data.msg,', response.data);
  137. uni.showLoading({
  138. title: response.data.msg
  139. });
  140. uni.hideLoading();
  141. uni.navigateBack({
  142. delta: 2
  143. });
  144. });
  145. })
  146. .catch(err => {
  147. uni.showToast({
  148. icon: 'none',
  149. title: '错误!' + err[0].message
  150. })
  151. console.log('err错误信息为:', err);
  152. });
  153. },
  154. // 隐藏键盘
  155. hideKeyboard() {
  156. uni.hideKeyboard();
  157. },
  158. // 单位成立时间
  159. ActiveUnitTime(e) {
  160. this.unitTime = false;
  161. let value = new Date(e.value);
  162. console.log(e.value, e.mode);
  163. this.formData.qhsj = uni.$u.timeFormat(e.value, 'yyyy-mm-dd');
  164. },
  165. changetime(e) {
  166. console.log('change', e);
  167. },
  168. // 生成隐患弹出层 //暂存为草稿箱弹出层
  169. cancel() {
  170. this.show = false;
  171. },
  172. confirm() {
  173. setTimeout(() => {
  174. // 0.5秒后自动关闭
  175. this.show = false;
  176. }, 500);
  177. },
  178. // 触底的事件
  179. scrolltolower() {
  180. // 判断是否还有下一页数据
  181. if (this.pageNo * this.pageSize >= this.total)
  182. return uni.showToast({
  183. title: `数据加载完毕`
  184. });
  185. // 判断是否正在请求其它数据,如果是,则不发起额外的请求
  186. if (this.loading) return;
  187. this.pageNo += 1;
  188. this.showCheckboxShow(this.pageNo);
  189. }
  190. }
  191. };
  192. </script>
  193. <style lang="scss" scoped>
  194. page {
  195. height: 100%;
  196. background-color: #f5f7f9;
  197. position: relative;
  198. }
  199. body {
  200. background-color: #f5f7f9;
  201. }
  202. .buttomBorder {
  203. height: 0px;
  204. border: 1px dashed #cbd5e1;
  205. }
  206. /deep/ .uni-section .uni-section-header {
  207. padding: 0px;
  208. }
  209. /deep/ .u-form-item__body {
  210. font-weight: 500;
  211. flex-direction: column !important;
  212. }
  213. /deep/ .u-form-item__body__left__content__label {
  214. margin-bottom: 16rpx;
  215. font-size: 30rpx !important;
  216. color: #274647 !important;
  217. }
  218. .arrow-icon {
  219. //主动检查箭头
  220. position: absolute;
  221. right: 14px;
  222. top: 49px;
  223. transform: rotate(90deg);
  224. }
  225. /deep/ .u-input[data-v-fdbb9fe6],
  226. /deep/ .u-input.data-v-fdbb9fe6,
  227. /deep/ .u-input {
  228. background-color: #fff;
  229. }
  230. /deep/.u-button[data-v-3bf2dba7],
  231. /deep/.u-button.data-v-3bf2dba7,
  232. /deep/.u-button {
  233. width: 60% !important;
  234. }
  235. //弹框样式
  236. .btnList {
  237. // width: 40%;
  238. display: flex;
  239. // display:flex;
  240. .u-button[data-v-3bf2dba7],
  241. .u-button {
  242. width: 30%;
  243. }
  244. }
  245. /deep/ .u-popup__content {
  246. //弹出的宽高
  247. height: 100%;
  248. }
  249. /deep/ .u-form-item__body__right__message {
  250. //校验的文字的位置
  251. margin-left: 10rpx !important;
  252. }
  253. /deep/ .uicon-close {
  254. //关闭按钮背景色
  255. background-color: rgba(199, 203, 210, 0.9);
  256. border-radius: 10%;
  257. }
  258. .checkbox {
  259. .checkbox-item {
  260. box-sizing: border-box;
  261. padding-top: 40px;
  262. }
  263. }
  264. //侧边联动
  265. .page-body {
  266. display: flex;
  267. background: #fff;
  268. overflow: hidden;
  269. }
  270. .nav {
  271. display: flex;
  272. width: 100%;
  273. }
  274. .nav-left {
  275. width: 25%;
  276. background: #fafafa;
  277. }
  278. .nav-left-item {
  279. height: 100upx;
  280. border-right: solid 1px #f1f1f1;
  281. border-bottom: solid 1px #f1f1f1;
  282. font-size: 30upx;
  283. display: flex;
  284. align-items: center;
  285. justify-content: center;
  286. }
  287. /deep/.nav-right-item[data-v-73caef23],
  288. /deep/.nav-right-item {
  289. display: flex;
  290. flex-wrap: wrap;
  291. }
  292. .nav-left-item:last-child {
  293. border-bottom: none;
  294. }
  295. .nav-right {
  296. width: 75%;
  297. }
  298. .box {
  299. display: block;
  300. overflow: hidden;
  301. border-bottom: 20upx solid #f3f3f3;
  302. /* min-height: 100vh; */
  303. /*若您的子分类过少想使得每个子分类占满屏请放开上边注视 */
  304. }
  305. .box:last-child {
  306. border: none;
  307. // min-height: 100vh;
  308. }
  309. .nav-right-item {
  310. margin-top: 20px;
  311. // width: 28%;
  312. // min-height: 200upx;
  313. float: left;
  314. text-align: center;
  315. padding: 11upx;
  316. font-size: 28upx;
  317. background: #fff;
  318. /deep/.u-checkbox__icon-wrap[data-v-532d01c7],
  319. /deep/.u-checkbox__icon-wrap {
  320. //复选框的样式
  321. margin: 0 20rpx;
  322. }
  323. /deep/ uni-view[data-v-3d1b15f2] {
  324. //复选框上线的间距
  325. margin: 20rpx 0 !important;
  326. }
  327. // /deep/ .u-checkbox__icon-wrap--square{
  328. // margin: 20rpx;
  329. // }
  330. .u-checkbox-label--right[data-v-532d01c7],
  331. .u-checkbox-label--right {
  332. margin-right: 40rpx;
  333. }
  334. }
  335. .nav-right-item image {
  336. width: 150upx;
  337. height: 150upx;
  338. }
  339. .active {
  340. font-weight: 700;
  341. color: #274647;
  342. background: #fff;
  343. border-right: 0;
  344. }
  345. ::-webkit-scrollbar {
  346. /*取消小程序的默认导航条样式*/
  347. width: 0;
  348. height: 0;
  349. color: transparent;
  350. }
  351. .selectBtn {
  352. width: 200rpx;
  353. margin-left: 0;
  354. font-size: 30rpx;
  355. background-color: #4cb2b6;
  356. }
  357. .example {
  358. overflow-y: auto;
  359. }
  360. </style>