add_check.vue 33 KB

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