add_check.vue 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120
  1. <template>
  2. <view class="container uni-container">
  3. <view class="example">
  4. <!-- 自定义表单校验 1-->
  5. <u--form ref="customForm" :model="formData" labelPosition="left" labelWidth="70" labelAlign="right">
  6. <view class=" flex flex-direction ">
  7. <u-form-item label="任务名称" prop="taskName" :required="true">
  8. <u-input v-model="formData.taskName" placeholder="请输入项目名称" />
  9. </u-form-item>
  10. <u-form-item label="所属单位" prop="orgId" @click="showSex(); hideKeyboard()" :required="true">
  11. <u--input suffixIcon="arrow-right" suffixIconStyle="color: #909399" v-model="formData.orgId"
  12. disabled disabledColor="#ffffff" placeholder="请选择所属单位">
  13. </u--input>
  14. </u-form-item>
  15. <!-- <u-form-item label="所属部门" prop="deptId" @click="showSex3(); hideKeyboard()">
  16. <u--input suffixIcon="arrow-right" suffixIconStyle="color: #909399" v-model="formData.deptId"
  17. disabled disabledColor="#ffffff" placeholder="请选择所属部门 (注:单位/部门二选一)">
  18. </u--input>
  19. </u-form-item> -->
  20. <u-form-item label="检查项目" :required="true" prop="inspectIds"
  21. @click="showCheckboxShow(); hideKeyboard()">
  22. <u--input suffixIcon="arrow-right" suffixIconStyle="color: #909399"
  23. v-model="formData.inspectIds" disabled disabledColor="#ffffff" placeholder="请选择检查项目">
  24. </u--input>
  25. </u-form-item>
  26. </view>
  27. <u-form-item label="巡查内容补充" prop="taskContent" class="xuncha" label-width="220rpx">
  28. <u--textarea v-model="formData.taskContent" placeholder="请输入内容" :maxlength="200" count height="100">
  29. </u--textarea>
  30. </u-form-item>
  31. <u-form-item label="上传附件">
  32. <!-- 选择文件上传,limit="1则最多选择一张图片,del-icon隐藏删除按钮 -->
  33. <uni-file-picker v-model="formData.attId" del-icon limit="1" auto-upload file-mediatype="all"
  34. @select="select" @delete="deleteFile">
  35. <button type="primary" class="selectBtn">选择文件</button>
  36. <!-- 加载中 -->
  37. <isLodingModel v-if="loading"></isLodingModel>
  38. </uni-file-picker>
  39. </u-form-item>
  40. <u-form-item label="已上传附件" v-if="bianji&&formData.attId.length" labelWidth="100">
  41. <u-icon name="close" color="#4CB2B6" size="24" @click="closeImage()">
  42. </u-icon>
  43. <!-- #ifdef MP-WEIXIN -->
  44. <text style="color:#00a3f4;cursor: pointer;margin-left: 50rpx !important;"
  45. @click.native="viewSee(formData.attId[0])">点击预览文件</text>
  46. <!-- #endif -->
  47. <!-- #ifdef H5 -->
  48. <a style="color:#00a3f4;cursor: pointer;margin-left: 50rpx !important;" @click="viewSee(formData.attId[0])">点击预览文件</a>
  49. <!-- #endif -->
  50. </u-form-item>
  51. <uni-row class="zan-cun">
  52. <!-- <uni-col :span="12">
  53. <u-button @click="submit('customForm')" type="primary" shape="circle" size="default"
  54. color="#4CB2B6" text="立即发布">
  55. :text="bianji?'确认修改':'确认提交'"
  56. </u-button>
  57. </uni-col> -->
  58. <uni-col :span="24">
  59. <!-- <u-modal :show="show" :title="title" :content='content' :asyncClose="true" @cancel="cancel"
  60. @confirm="confirm" :showCancelButton='true' :showConfirmButton='true'></u-modal> -->
  61. <u-button @click="submit('customForm')" type="primary" color="#4CB2B6" shape="circle"
  62. size="default" text="暂存"></u-button>
  63. <u-modal :show="showNew" title="已存入草稿箱,是否立即发布" @confirm="sureNew" @cancel="cancelNew"
  64. :showCancelButton='true' :showConfirmButton='true'></u-modal>
  65. </uni-col>
  66. </uni-row>
  67. </u--form>
  68. <!-- 多选closeable closeOnClickOverlay--点击遮罩层不可关闭所属单位的弹出内容选中 ,选择单位-->
  69. <u-popup :show="checkboxShow2" :round="10" @close="checkboxShow2=false" style="position: relative;">
  70. <!-- <view class="u-page__tag-item">
  71. <u-search placeholder="请输入所属单位" v-model="keyword" bgColor="#edf6f9" borderColor="#4cb2b6"
  72. :show-action="false"></u-search>
  73. </view> -->
  74. <view class="popup-button">
  75. <uni-row>
  76. <uni-col :span='12'>
  77. <u-button shape="circle" type="primary" color="#4CB2B6" text="确定" @click="checkboxConfirm2">
  78. </u-button>
  79. </uni-col>
  80. <uni-col :span='12'>
  81. <u-button type="primary" plain color="#4CB2B6" text="取消" shape="circle"
  82. @click="checkboxCancel2">
  83. </u-button>
  84. </uni-col>
  85. </uni-row>
  86. </view>
  87. <view class="page-body" :style="'height:' + (height-80)+ 'px'">
  88. <scroll-view class="nav-left" scroll-y :style="'height:' + height + 'px'"
  89. :scroll-top="scrollLeftTop" scroll-with-animation>
  90. <view class="nav-left-item" :class="index == categoryActive ? 'active' : ''"
  91. v-for="(item, index) in list2" @click="categoryClickMain(index,item)" :key="index">
  92. {{item[0]}}
  93. </view>
  94. </scroll-view>
  95. <scroll-view class="nav-right" scroll-y :scroll-top="scrollTop" @scroll="scroll"
  96. :style="'height:' + height + 'px'" scroll-with-animation>
  97. <view v-for="(item, index) in list2" :key="index" class="box">
  98. <view style="height: 60rpx;font-size: 32rpx;color:#000;font-weight: 600;padding: 25rpx;">
  99. {{ item[0]}}
  100. </view>
  101. <!-- <view :id="i == 0 ? 'first' : ''" class="nav-right-item"> -->
  102. <view class="nav-right-item">
  103. <u-checkbox-group size='20' iconSize='18' placement="row" iconPlacement='right'
  104. v-model="items.checkedList2" v-for="(items, i) in item" :key="i"
  105. @change="checkboxChange2(items.dwid,$event)">
  106. <u-checkbox v-if="i>0" activeColor="green" :customStyle="{marginBottom: '5px'}"
  107. :label="items.orgName" :name="items.dwid">
  108. </u-checkbox>
  109. </u-checkbox-group>
  110. </view>
  111. </view>
  112. </scroll-view>
  113. </view>
  114. </u-popup>
  115. <!-- 多选closeable closeOnClickOverlay--点击遮罩层不可关闭检查项的弹出内容选中 选择检查项-->
  116. <u-popup :show="checkboxShow" :round="10" @close="checkboxShow=false" style="position: relative;">
  117. <!-- <view class="u-page__tag-item">
  118. <u-search placeholder="请输入检查项" v-model="keyword" bgColor="#edf6f9" borderColor="#4cb2b6"
  119. :show-action="false"></u-search>
  120. </view> -->
  121. <view class="popup-button">
  122. <uni-row>
  123. <uni-col :span='12'>
  124. <u-button shape="circle" type="primary" color="#4CB2B6" text="确定" @click="checkboxConfirm">
  125. </u-button>
  126. </uni-col>
  127. <uni-col :span='12'>
  128. <u-button type="primary" plain color="#4CB2B6" text="取消" shape="circle"
  129. @click="checkboxCancel">
  130. </u-button>
  131. </uni-col>
  132. </uni-row>
  133. </view>
  134. <view class="page-body" :style="'height:' +(height-80) + 'px'">
  135. <scroll-view class="nav-left" scroll-y :style="'height:' + (height-100) + 'px'"
  136. :scroll-top="scrollLeftTop" scroll-with-animation>
  137. <view class="nav-left-item" :class="index == categoryActive ? 'active' : ''"
  138. v-for="(item, index) in list" @click="categoryClickMain(index,item)" :key="index">
  139. {{ item.label }}
  140. </view>
  141. </scroll-view>
  142. <scroll-view class="nav-right" scroll-y :scroll-top="scrollTop" @scroll="scroll"
  143. :style="'height:' + height + 'px'" scroll-with-animation>
  144. <view v-for="(item, index) in list" :key="index" class="box">
  145. <view style="height: 60rpx;font-size: 32rpx;color:#000;font-weight: 600;padding: 25rpx;">
  146. {{item.label}}
  147. </view>
  148. <!-- <view :id="i == 0 ? 'first' : ''" class="nav-right-item"> -->
  149. <view class="nav-right-item">
  150. <u-checkbox-group size='20' iconSize='18' placement="row" iconPlacement='right'
  151. v-model="items.checkedList" v-for="(items, i) in item.inspectInfoDOList" :key="i"
  152. @change="checkboxChange(items.id,$event)">
  153. <u-checkbox activeColor="green" :customStyle="{marginBottom: '5px'}"
  154. :label="items.inspName" :name="items.id">
  155. </u-checkbox>
  156. </u-checkbox-group>
  157. </view>
  158. </view>
  159. </scroll-view>
  160. </view>
  161. </u-popup>
  162. <!-- 多选closeable closeOnClickOverlay--点击遮罩层不可关闭所属部门的弹出内容选中 ,选择部门-->
  163. <u-popup :show="checkboxShow3" :round="10" @close="checkboxShow3=false" style="position: relative;">
  164. <view class="popup-button">
  165. <uni-row>
  166. <uni-col :span='12'>
  167. <u-button shape="circle" type="primary" color="#4CB2B6" text="确定" @click="checkboxConfirm3">
  168. </u-button>
  169. </uni-col>
  170. <uni-col :span='12'>
  171. <u-button type="primary" plain color="#4CB2B6" text="取消" shape="circle"
  172. @click="checkboxCancel3">
  173. </u-button>
  174. </uni-col>
  175. </uni-row>
  176. </view>
  177. <view class="page-body" :style="'height:' + height + 'px'">
  178. <scroll-view class="nav-left" scroll-y :style="'height:' + height + 'px'"
  179. :scroll-top="scrollLeftTop" scroll-with-animation>
  180. <view class="nav-left-item" :class="index == categoryActive ? 'active' : ''"
  181. v-for="(item, index) in list3Jia" @click="categoryClickMain(index,item)" :key="index">
  182. {{ item.name}}
  183. </view>
  184. </scroll-view>
  185. <scroll-view class="nav-right" scroll-y :scroll-top="scrollTop" @scroll="scroll"
  186. :style="'height:' + height + 'px'" scroll-with-animation>
  187. <view v-for="(item, index) in list3Jia" :key="index" class="box">
  188. <view style="height: 60rpx;font-size: 32rpx;color:#000;font-weight: 600;padding: 25rpx;">
  189. {{ `单位${item.id}` }}
  190. </view>
  191. <!-- <view :id="i == 0 ? 'first' : ''" class="nav-right-item"> -->
  192. <view class="nav-right-item">
  193. <u-checkbox-group size='20' iconSize='18' placement="row" iconPlacement='right'
  194. v-model="items.checkedList3" v-for="(items, i) in list3" :key="i"
  195. @change="checkboxChange3(items.id,$event)">
  196. <u-checkbox activeColor="green" :customStyle="{marginBottom: '5px'}"
  197. :label="items.name" :name="items.id">
  198. </u-checkbox>
  199. </u-checkbox-group>
  200. </view>
  201. </view>
  202. </scroll-view>
  203. </view>
  204. </u-popup>
  205. <!-- <image :src="jiezhiTime" mode="heightFix" style="width: 20px;height: 20px;"></image> -->
  206. </view>
  207. </view>
  208. </template>
  209. <script>
  210. import {
  211. addCheckActiveCreate, // 主动检查添加
  212. addCheckActiveErrorsubmit, // 主动检查生成隐患
  213. addCheckActiveCompany, //所属单位
  214. jiase, //检查项数据列表
  215. addCheckActiveDepartment, //所属部门
  216. editCheckActiveCreate, //编辑主动检查
  217. getCheckActiveTask, //获取编辑主动检查的数据
  218. getCheckActiveTaskXin, //最新--获取编辑主动检查的数据
  219. saveCheckRelease
  220. } from "@/api/check_active";
  221. import {
  222. uploadAvatar
  223. } from "@/api/system/user"
  224. import {
  225. getAccessToken
  226. } from '@/utils/auth'
  227. import {
  228. downSee,
  229. checkType
  230. } from '@/utils/common'
  231. import config from '@/config'
  232. import store from "@/store"
  233. const baseUrl = config.baseUrl
  234. let that = null;
  235. export default {
  236. data() {
  237. return {
  238. keyword: '',
  239. list3Jia: [{
  240. name: '测试部门'
  241. }],
  242. showNew: false, //确认立即发布弹框
  243. showGender: false, //所属单位下拉框展示
  244. //————————————下拉结束
  245. checkboxShow: false, //选择检查项目弹框
  246. checkboxShow2: false, //选择检查单位弹框
  247. checkboxShow3: false, //选择检查部门弹框
  248. checkedList: [], //检查项目已选择列表
  249. checkedList2: [], //检查单位已选择列表
  250. checkedList3: [], //检查部门已选择列表
  251. // 生成隐患弹窗
  252. show: false,
  253. list: [], //选择检查项目的数据
  254. list2: [], //选择单位项目的数据
  255. list3: [], //选择单位项目的数据
  256. // 每页数据量
  257. pageSize: 5,
  258. // 当前页
  259. pageNo: 1,
  260. // 数据总量
  261. total: 0,
  262. // tableData数据加载中
  263. tableData: '',
  264. loading: false,
  265. title: '生成隐患',
  266. content: '确认将此检查项目生成为隐患',
  267. // 自定义表单数据
  268. formData: {
  269. taskName: '', //任务名称
  270. inspectIds: '', //检查项目
  271. taskContent: '', //任务描述
  272. orgId: '', //页面上显示的检查单位
  273. deptId: '', //页面上显示的部门
  274. attId: [], //附件
  275. },
  276. formDataChuangMu: {
  277. "deptId": [],
  278. // "attId": 0,
  279. "inspectIds": [],
  280. "orgId": [], //检查单位id
  281. // "orgType": "",
  282. "status": 0, //0代表启用
  283. "taskContent": "", //任务描述
  284. "sender": this.$store.state.user.id,
  285. // "taskId": 0,
  286. "taskName": "", //任务名称
  287. // "taskScore": 0,
  288. "taskStatus": "0",
  289. "taskType": "", //任务类型 1对应主动检查
  290. "attId": ''
  291. },
  292. fileList1: [],
  293. // 自定义表单校验规则
  294. customRules: {
  295. taskName: {
  296. status: 'string',
  297. required: true,
  298. message: '任务名称需在2-20个字符之间',
  299. trigger: ['blur', 'change'],
  300. min: 2,
  301. max: 20,
  302. },
  303. inspectIds: {
  304. status: 'string',
  305. required: true,
  306. message: '检查项目不能为空',
  307. trigger: ['blur', 'change']
  308. },
  309. orgId: {
  310. status: 'string',
  311. required: true,
  312. message: '所属单位不能为空',
  313. trigger: ['blur', 'change']
  314. },
  315. // deptId:{
  316. // status: 'string',
  317. // required: true,
  318. // message: '所属部门不能为空',
  319. // trigger: ['blur', 'change']
  320. // }
  321. },
  322. bianji: false, //是否编辑进来的
  323. ids: '', //创建成功的id
  324. //侧边栏联动
  325. height: 0,
  326. categoryActive: 0,
  327. scrollTop: 0,
  328. scrollLeftTop: 0,
  329. arr: [0, 584, 1168, 1752, 2336, 2805, 3274, 3858, 4442, 4911, 5380, 5734, 6203, 6672,
  330. 7017
  331. ], //初始值,后边计算会根据手机适配覆盖
  332. leftItemHeight: 51, //49行会计算出新值进行覆盖
  333. navLeftHeight: 0, //左边scroll-view 内层nav的总高度
  334. diff: 0, //左边scroll-view 内层nav的总高度与视口之差
  335. tabBarHeight: 0 //如果此页面为Tab页面,自己改变高度值,,一般tab高度为51
  336. }
  337. },
  338. computed: {},
  339. watch: {
  340. loading: {
  341. handler(newLength, oldLength) {
  342. this.$modal.isLoadingModel(this.loading)
  343. },
  344. immediate: true
  345. }
  346. },
  347. // 在 vue页面,向起始页通过事件传递数据
  348. onLoad: function(option) {
  349. console.log(option, 'mmmmmmmmm');
  350. this.formDataChuangMu.taskType = option.type
  351. if (option.id) {
  352. this.bianji = true
  353. const ids = parseInt(option.id)
  354. const json = JSON.stringify({
  355. id: ids,
  356. // pageNo: this.pageNo,
  357. // pagesSize: this.pageSize
  358. })
  359. getCheckActiveTaskXin({
  360. id: ids
  361. }).then(response => { //获取编辑主动检查的数据
  362. console.log(response,'responseresponse');
  363. const res = response.data
  364. this.formData.taskName = res.taskInfo.taskName
  365. this.formData.taskContent = res.taskInfo.taskContent
  366. this.formData.attId[0]= res.taskInfo.attId?res.taskInfo.attId:''
  367. this.formDataChuangMu.attId= res.taskInfo.attId?res.taskInfo.attId:''
  368. if (res.orgList&&res.orgList.length != 0) {
  369. let item = []
  370. res.orgList.map(v => { //单位
  371. this.formDataChuangMu.orgId.push(v.id)
  372. item.push(v.orgName)
  373. })
  374. this.formData.orgId = item.join(',')
  375. }
  376. if (res.inspectList.length != 0) {
  377. let arr = []
  378. res.inspectList.map(v => { //项目
  379. this.formDataChuangMu.inspectIds.push(v.id)
  380. arr.push(v.inspName)
  381. })
  382. this.formData.inspectIds = arr.join(',')
  383. }
  384. // if (res.deptList.length != 0) {
  385. // this.formData.deptId = '已选择部门'
  386. // res.deptList.map(v => { //部门
  387. // this.formDataChuangMu.deptId.push(v.id)
  388. // })
  389. // }
  390. });
  391. this.formDataChuangMu["id"] = ids
  392. }
  393. },
  394. onReady() {
  395. // this.checkedTotal3(this.pageNo) 部门
  396. this.checkedTotal(this.pageNo)
  397. this.getData(this.pageNo)
  398. this.height = uni.getSystemInfoSync().windowHeight - this.tabBarHeight
  399. // 设置自定义表单校验规则,必须在节点渲染完毕后执行
  400. this.$refs.customForm.setRules(this.customRules)
  401. },
  402. methods: {
  403. closeImage(){
  404. this.formData.attId=[]
  405. this.formDataChuangMu.attId =''
  406. this.$forceUpdate()
  407. },
  408. //查看已上传附件
  409. viewSee(val){
  410. downSee(val)
  411. },
  412. //上传文件
  413. selectBtn() {
  414. this.$refs.files.upload()
  415. },
  416. // 隐藏键盘
  417. hideKeyboard() {
  418. uni.hideKeyboard()
  419. },
  420. // 生成隐患弹出层 //暂存为草稿箱弹出层
  421. cancel() {
  422. this.show = false;
  423. },
  424. confirm() {
  425. setTimeout(() => {
  426. // 0.5秒后自动关闭
  427. this.show = false;
  428. }, 500)
  429. },
  430. //popup检查项确定
  431. checkboxConfirm() {
  432. this.checkboxShow = false
  433. let arr = []
  434. this.checkedList.map(v => {
  435. v.map(i => {
  436. arr.push(i)
  437. })
  438. })
  439. this.formDataChuangMu.inspectIds = [...new Set(arr)]
  440. let items = []
  441. if (this.checkedList.length != 0) {
  442. this.list.map(i => {
  443. i.inspectInfoDOList.map(k => {
  444. this.formDataChuangMu.inspectIds.map(j => {
  445. if (k.id == j) {
  446. items.push(k.inspName)
  447. }
  448. })
  449. })
  450. })
  451. this.formData.inspectIds = items.join(',')
  452. } else {
  453. this.formData.inspectIds = ''
  454. }
  455. },
  456. //popup取消
  457. checkboxCancel() {
  458. this.checkboxShow = false
  459. this.checkedList = []
  460. this.formData.inspectIds = ''
  461. },
  462. //popup检查单位确定============
  463. checkboxConfirm2() {
  464. this.checkboxShow2 = false
  465. let arr = []
  466. console.log(this.checkedList2,'this.checkedList2');
  467. this.checkedList2.map(v => {
  468. v.map(i => {
  469. arr.push(i)
  470. })
  471. })
  472. this.formDataChuangMu.orgId = [...new Set(arr)]
  473. let items = []
  474. if (this.checkedList2.length != 0) {
  475. for (let v in this.list2) {
  476. this.list2[v].map(i => {
  477. // i.map(k => {
  478. this.formDataChuangMu.orgId.map(j => {
  479. if (i.dwid == j) {
  480. items.push(i.orgName)
  481. }
  482. })
  483. // })
  484. })
  485. }
  486. this.formData.orgId = items.join(',')
  487. } else {
  488. this.formData.orgId = ''
  489. }
  490. },
  491. //popup取消
  492. checkboxCancel2() {
  493. this.checkboxShow2 = false
  494. this.checkedList2 = []
  495. this.formData.orgId = ''
  496. },
  497. //========
  498. // //popup检查部门确定============
  499. // checkboxConfirm3() {
  500. // this.checkboxShow3 = false
  501. // this.checkedList3.map(v => {
  502. // v.map(i => {
  503. // this.formDataChuangMu.deptId.push(i)
  504. // })
  505. // })
  506. // if (this.checkedList3.length != 0) {
  507. // this.formData.deptId = '已选择部门'
  508. // }else{
  509. // this.formData.deptId =''
  510. // }
  511. // },
  512. // //popup取消
  513. // checkboxCancel3() {
  514. // this.checkboxShow3 = false
  515. // this.checkedList3 = []
  516. // this.formData.deptId =''
  517. // },
  518. // checkboxChange3(i, n) {
  519. // if (i && n.length != 0) {
  520. // this.checkedList3.push(n)
  521. // } else if (i && n.length == 0) {
  522. // this.checkedList3 = this.checkedList3.filter(item => item != i)
  523. // }
  524. // console.log(this.checkedList3, 'this.checkedList3');
  525. // },
  526. // // 展示部门选择的弹出层
  527. // showSex3(pageNo, value = '') {
  528. // this.checkboxShow3 = true
  529. // },
  530. // checkedTotal3(pageNo) { //部门
  531. // this.loading = true
  532. // this.pageNo = pageNo
  533. // addCheckActiveDepartment({}).then(response => { //所属部门数据列表
  534. // console.log(response, 'response部门');
  535. // this.list3 = response.data
  536. // console.log(this.list3, 'this.list3');
  537. // const json = JSON.stringify({
  538. // id: this.formDataChuangMu["id"],
  539. // pageNo: this.pageNo,
  540. // pagesSize: this.pageSize
  541. // })
  542. // if (this.bianji) {
  543. // getCheckActiveTaskXin({
  544. // id: this.formDataChuangMu["id"]
  545. // }).then(response => { //获取编辑所属部门的数据
  546. // const res = response.data
  547. // res.deptList.map(
  548. // v => { //进入编辑界面以前勾选的所属部门把他放进this.list[0].deptList.中添加一个checkedList
  549. // this.list3.map(listK => {
  550. // if (v.id == listK.id) {
  551. // listK.checkedList3 = [v.id]
  552. // }
  553. // })
  554. // this.checkedList3.push([v.id]) //这句话有问题 传到后端的数据
  555. // })
  556. // });
  557. // }
  558. // });
  559. // },
  560. //========
  561. checkboxChange(i, n) { //输出的是选中的项目id数组
  562. if (i && n.length != 0) {
  563. this.checkedList.push(n)
  564. } else if (i && n.length == 0) {
  565. this.checkedList = this.checkedList.filter(item => item != i)
  566. }
  567. },
  568. checkboxChange2(i, n) {
  569. if (i && n.length != 0) {
  570. this.checkedList2.push(n)
  571. } else if (i && n.length == 0) {
  572. this.checkedList2 = this.checkedList2.filter(item => item != i)
  573. }
  574. },
  575. // 展示检查项的弹出层
  576. showCheckboxShow(pageNo, value = '') {
  577. this.checkboxShow = true
  578. // this.checkedTotal(this.pageNo)
  579. },
  580. // 展示单位选择的弹出层
  581. showSex(pageNo, value = '') {
  582. this.checkboxShow2 = true
  583. },
  584. checkedTotal(pageNo) {
  585. this.pageNo = pageNo
  586. jiase({
  587. inspType: 'dict_inspect_type'
  588. }).then(response => { //检查项数据列表
  589. this.list = response.data
  590. const json = JSON.stringify({
  591. id: this.formDataChuangMu["id"],
  592. // pageNo: this.pageNo,
  593. // pagesSize: this.pageSize
  594. })
  595. if (this.bianji) {
  596. getCheckActiveTaskXin({
  597. id: this.formDataChuangMu["id"]
  598. }).then(response => { //获取编辑主动检查项的数据
  599. const res = response.data
  600. res.inspectList.map(
  601. v => { //进入编辑界面以前勾选的检查项把他放进this.list[0].inspectInfoDOList中添加一个checkedList
  602. this.list.map(i => {
  603. i.inspectInfoDOList.map(listK => {
  604. if (v.id == listK.id) {
  605. listK.checkedList = [v.id]
  606. }
  607. })
  608. })
  609. this.checkedList.push([v.id]) //这句话有问题 传到后端的数据
  610. })
  611. });
  612. }
  613. });
  614. },
  615. //侧边栏导航联动
  616. getHeightList() {
  617. let _this = this;
  618. let selectorQuery = uni.createSelectorQuery();
  619. selectorQuery.selectAll('.nav-left-item').boundingClientRect(function(rects) {
  620. _this.leftItemHeight = rects[0].height;
  621. _this.navLeftHeight = _this.leftItemHeight * this.list.length;
  622. _this.diff = _this.navLeftHeight - _this.height;
  623. });
  624. selectorQuery.selectAll('.box').boundingClientRect(function(rects) {
  625. let arr = [0];
  626. let top = 0;
  627. if (rects) {
  628. rects.forEach(function(rect) {
  629. top += rect.height;
  630. arr.push(top);
  631. });
  632. };
  633. _this.arr = arr;
  634. }).exec();
  635. },
  636. scroll(e) {
  637. let _this = this;
  638. if (this.timeoutId) {
  639. clearTimeout(this.timeoutId);
  640. }
  641. this.timeoutId = setTimeout(function() {
  642. //节流
  643. _this.scrollHeight = e.detail.scrollTop + 1 + _this.height / 2;
  644. //+1不要删除,解决最后一项某种情况下翻到底部,左边按钮并不会切换至最后一个
  645. //若想使切换参考线为屏幕顶部请删除 _this.height/2
  646. for (let i = 0; i < _this.arr.length; i++) {
  647. let height1 = _this.arr[i];
  648. let height2 = _this.arr[i + 1];
  649. if (!height2 || (_this.scrollHeight >= height1 && _this.scrollHeight < height2)) {
  650. _this.categoryActive = i;
  651. _this.diff > 0 && (_this.scrollLeftTop = Math.round((_this.categoryActive * _this
  652. .diff) / (this.list.length - 1)));
  653. return false;
  654. }
  655. }
  656. _this.categoryActive = 0;
  657. _this.timeoutId = undefined;
  658. }, 10);
  659. },
  660. categoryClickMain(index, item) {
  661. this.categoryActive = index;
  662. this.scrollTop == this.arr[index] ? (this.scrollTop = this.scrollTop + 1) : (this.scrollTop = this.arr[
  663. index]); //防止两次相等造成点击不触发滚动时间
  664. },
  665. getData(pageNo, value = '') {
  666. // this.loading = true
  667. this.pageNo = pageNo
  668. const form = {
  669. // pageNo: this.pageNo,
  670. // pageSize: this.pageSize,
  671. userId: this.$store.state.user.id
  672. }
  673. addCheckActiveCompany( //获取所属单位JSON.stringify(form)
  674. form
  675. ).then(response => {
  676. // response.data.map((v,index)=>{
  677. // console.log(index,'indexindexindexindex');
  678. // })
  679. // for(let key in response.data){
  680. // key=checkType('backend_org_type',key)
  681. // }
  682. for (let key in response.data) {
  683. response.data[key].unshift(checkType('backend_org_type', key))
  684. }
  685. this.list2 = response.data
  686. const json = JSON.stringify({
  687. id: this.formDataChuangMu["id"],
  688. pageNo: this.pageNo,
  689. pagesSize: this.pageSize
  690. })
  691. if (this.bianji) {
  692. getCheckActiveTaskXin({
  693. id: this.formDataChuangMu["id"]
  694. }).then(response => { //获取编辑主动检查单位的数据
  695. console.log(response,'ressss');
  696. const res = response.data
  697. for (let g in this.list2) {
  698. // g.map(v => { //进入编辑界面以前勾选的检查项把他放进this.list.orgList中添加一个checkedList
  699. this.list2[g].map(i => {
  700. // i.orgDOList.map(listK => {
  701. if (i.id == this.list2[g].id) {
  702. console.log(i,'[i.id][i.id][i.id]',this.list2);
  703. this.list2[g].checkedList2 = [i.id]
  704. }
  705. // })
  706. })
  707. this.checkedList2.push([this.list2[g].id]) //这句话有问题 传到后端的数据
  708. // })
  709. }
  710. });
  711. }
  712. });
  713. },
  714. sureNew() { //确认发布
  715. saveCheckRelease({
  716. id: this.ids
  717. }).then(response => {
  718. if (response.data) {
  719. uni.showToast({
  720. title: `发布成功`
  721. })
  722. setTimeout(() => {
  723. uni.redirectTo({
  724. url: `/pagesA/fire/check_active/index?current=2&type=${this.formDataChuangMu.taskType}`
  725. });
  726. }, 500);
  727. }
  728. })
  729. this.showNew = false
  730. },
  731. cancelNew() { //取消发布--暂存
  732. this.showNew = false
  733. console.log(this.formDataChuangMu.taskType, 'this.formDataChuangMu.taskType');
  734. setTimeout(() => {
  735. setTimeout(() => {
  736. uni.redirectTo({
  737. url: `/pagesA/fire/check_active/index?current=3&type=${this.formDataChuangMu.taskType}`
  738. });
  739. }, 500);
  740. }, 0);
  741. },
  742. select(e) {
  743. // 根据所选图片的个数,多次调用上传函数
  744. let promises = [];
  745. for (let i = 0; i < e.tempFilePaths.length; i++) {
  746. const promise = this.uploadFiles(e.tempFilePaths, i);
  747. promises.push(promise);
  748. }
  749. Promise.all(promises).then(result => {});
  750. },
  751. // 上传文件函数
  752. async uploadFiles(tempFilePaths, i) {
  753. this.loading = true
  754. const that = this;
  755. await uni.uploadFile({
  756. url: baseUrl + '/admin-api/infra/file/upload', //后端用于处理图片并返回图片地址及文件的接口
  757. filePath: tempFilePaths[i],
  758. name: 'file',
  759. header: {
  760. Authorization: 'Bearer ' + getAccessToken()
  761. }, //请求token
  762. success: res => {
  763. let data = JSON.parse(res.data);
  764. this.formData.attId[0] = data.data
  765. this.formDataChuangMu.attId = data.data
  766. uni.showToast({
  767. title: '文件上传成功!'
  768. });
  769. that.loading = false
  770. },
  771. fail: () => {
  772. uni.showToast({
  773. icon: 'error',
  774. title: '文件上传失败!'
  775. });
  776. this.loading = false
  777. }
  778. });
  779. },
  780. // 移出图片函数
  781. async deleteFile(e) {
  782. this.formData.attId = [];
  783. // console.log('移除了:');
  784. },
  785. submit(ref) {
  786. this.$refs[ref].validate().then(res => {
  787. this.formDataChuangMu.taskContent = this.formData.taskContent
  788. this.formDataChuangMu.taskName = this.formData.taskName
  789. if (this.bianji) {
  790. editCheckActiveCreate(JSON.stringify(this.formDataChuangMu)).then(response => { //编辑接口
  791. if (response.code == 0) {
  792. uni.showToast({
  793. title: '创建成功'
  794. });
  795. this.showNew = true
  796. this.ids = response.data
  797. } else {
  798. uni.showToast({
  799. title: response.msg
  800. });
  801. }
  802. });
  803. } else {
  804. addCheckActiveCreate(JSON.stringify(this.formDataChuangMu)).then(response => { //修改接口
  805. if (response.code == 0) {
  806. this.showNew = true
  807. this.ids = response.data
  808. } else {
  809. uni.showToast({
  810. title: response.msg
  811. });
  812. }
  813. });
  814. }
  815. }).catch(err => {
  816. uni.$u.toast('校验失败')
  817. })
  818. },
  819. //
  820. // submitError(ref) {
  821. // this.$refs[ref].validate().then(res => {
  822. // console.log('success', res);
  823. // addCheckActiveErrorsubmit(this.formData).then(response => {
  824. // console.log('response.data.msg0,', response.data.msg);
  825. // uni.showLoading({
  826. // title: response.data.msg
  827. // });
  828. // setTimeout(() => {
  829. // uni.hideLoading();
  830. // this.$tab.navigateTo('/pagesA/fire/check_active/index')
  831. // }, 2000);
  832. // });
  833. // }).catch(err => {
  834. // console.log('err', err);
  835. // uni.$u.toast('校验失败')
  836. // })
  837. // },
  838. // 触底的事件
  839. scrolltolower() {
  840. // 判断是否还有下一页数据
  841. if (this.pageNo * this.pageSize >= this.total) return uni.showToast({
  842. title: `数据加载完毕`
  843. })
  844. // 判断是否正在请求其它数据,如果是,则不发起额外的请求
  845. if (this.loading) return
  846. this.pageNo += 1
  847. this.showCheckboxShow(this.pageNo)
  848. this.showSex(this.pageNo)
  849. },
  850. },
  851. }
  852. </script>
  853. <style lang="scss" scoped>
  854. page {
  855. height: 100%;
  856. background-color: #f5f7f9;
  857. position: relative;
  858. }
  859. .buttomBorder {
  860. height: 0px;
  861. border: 1px dashed #CBD5E1;
  862. }
  863. /deep/ .uni-section .uni-section-header {
  864. padding: 0px;
  865. }
  866. /deep/ .u-form-item__body {
  867. font-weight: 500;
  868. flex-direction: column !important;
  869. }
  870. /deep/ .u-form-item__body__left__content__label {
  871. width: 144rpx !important;
  872. margin-bottom: 16rpx;
  873. margin-left: 20rpx;
  874. font-size: 30rpx !important;
  875. color: #274647 !important;
  876. }
  877. .arrow-icon {
  878. //主动检查箭头
  879. position: absolute;
  880. right: 14px;
  881. top: 49px;
  882. transform: rotate(90deg);
  883. }
  884. /deep/ .u-input[data-v-fdbb9fe6],
  885. /deep/ .u-input.data-v-fdbb9fe6,/deep/ .u-input {
  886. background-color: #fff;
  887. }
  888. /deep/.u-button[data-v-3bf2dba7],
  889. /deep/.u-button.data-v-3bf2dba7,/deep/.u-button {
  890. width: 60% !important;
  891. }
  892. /deep/ .u-form-item__body__right__message {
  893. //校验的文字的位置
  894. margin-left: 10rpx !important;
  895. }
  896. /deep/ .uicon-close {
  897. //关闭按钮背景色
  898. // background-color: rgba(199, 203, 210, .9);
  899. border-radius: 10%;
  900. }
  901. //*号位置
  902. /deep/.u-form-item__body__left__content__required[data-v-5e7216f1],
  903. /deep/.u-form-item__body__left__content__required.data-v-5e7216f1,/deep/.u-form-item__body__left__content__required {
  904. left: 14rpx !important;
  905. }
  906. // 巡查内容补充的位置
  907. .xuncha {
  908. /deep/.u-form-item__body__left {
  909. width: 220rpx !important;
  910. }
  911. }
  912. .checkbox {
  913. .checkbox-item {
  914. box-sizing: border-box;
  915. padding-top: 40px;
  916. }
  917. }
  918. //侧边联动
  919. .page-body {
  920. display: flex;
  921. background: #fff;
  922. overflow: hidden;
  923. }
  924. .nav {
  925. display: flex;
  926. width: 100%;
  927. }
  928. .nav-left {
  929. width: 25%;
  930. background: #fafafa;
  931. }
  932. .nav-left-item {
  933. height: 150rpx;
  934. border-right: solid 1px #f1f1f1;
  935. border-bottom: solid 1px #f1f1f1;
  936. font-size: 30upx;
  937. display: flex;
  938. align-items: center;
  939. justify-content: center;
  940. }
  941. .nav-left-item:last-child {
  942. border-bottom: none;
  943. }
  944. .nav-right {
  945. width: 75%;
  946. }
  947. /deep/.nav-right-item {
  948. width: 100%;
  949. display: flex;
  950. flex-wrap: wrap;
  951. }
  952. /deep/.u-checkbox {
  953. width: 80% !important;
  954. margin-bottom: 30rpx !important;
  955. }
  956. /deep/ .u-checkbox-group {
  957. width: 100%;
  958. // justify-content: flex-end;
  959. }
  960. .box {
  961. display: block;
  962. overflow: hidden;
  963. border-bottom: 20upx solid #f3f3f3;
  964. /* min-height: 100vh; */
  965. /*若您的子分类过少想使得每个子分类占满屏请放开上边注视 */
  966. }
  967. .box:last-child {
  968. border: none;
  969. min-height: 100vh;
  970. }
  971. .u-checkbox-group--row.data-v-3d1b15f2 {
  972. display: flex;
  973. flex-direction: row;
  974. }
  975. .nav-right-item {
  976. margin-top: 20rpx;
  977. float: left;
  978. padding: 11upx;
  979. font-size: 28upx;
  980. background: #fff;
  981. /deep/.u-checkbox__icon-wrap[data-v-532d01c7],/deep/.u-checkbox__icon-wrap {
  982. //复选框的样式
  983. margin: 0 20rpx;
  984. }
  985. /deep/ uni-view[data-v-3d1b15f2] {
  986. //复选框上线的间距
  987. margin: 20rpx 0 !important;
  988. }
  989. // /deep/ .u-checkbox__icon-wrap--square{
  990. // margin: 20rpx;
  991. // }
  992. .u-checkbox-label--right[data-v-532d01c7],.u-checkbox-label--right{
  993. margin-right: 40rpx;
  994. }
  995. }
  996. .nav-right-item image {
  997. width: 150upx;
  998. height: 150upx;
  999. }
  1000. .active {
  1001. font-weight: 700;
  1002. color: #274647;
  1003. background: #fff;
  1004. border-right: 0;
  1005. }
  1006. ::-webkit-scrollbar {
  1007. /*取消小程序的默认导航条样式*/
  1008. width: 0;
  1009. height: 0;
  1010. color: transparent;
  1011. }
  1012. .selectBtn {
  1013. width: 200rpx;
  1014. margin-left: 0;
  1015. font-size: 30rpx;
  1016. background-color: #4cb2b6;
  1017. }
  1018. /deep/.uni-input-input,
  1019. /deep/.u-input__content__field-wrapper__field.data-v-fdbb9fe6 {
  1020. overflow: hidden;
  1021. -o-text-overflow: ellipsis;
  1022. text-overflow: ellipsis;
  1023. white-space: nowrap;
  1024. display: block;
  1025. }
  1026. /deep/ .u-checkbox uni-text,
  1027. /deep/ .u-checkbox text {
  1028. line-height: 40rpx !important;
  1029. white-space: normal;
  1030. word-break: break-all;
  1031. word-warp: break-word;
  1032. }
  1033. .popup-button {
  1034. width: 100%;
  1035. position: absolute;
  1036. left: 0;
  1037. bottom: 84rpx;
  1038. z-index: 9999;
  1039. }
  1040. .zan-cun,
  1041. /deep/ .uni-row {
  1042. margin-top: 200rpx;
  1043. }
  1044. .u-page__tag-item {
  1045. width: 90%;
  1046. margin: 30rpx 0;
  1047. margin-left: 5%;
  1048. }
  1049. .box[data-v-524457c8]:last-child,.box.data-v-524457c8:last-child,.box:last-child{
  1050. padding-bottom: 354rpx;
  1051. }
  1052. </style>