add_check.vue 33 KB

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