xunjiancz.js 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. import http from '../../base/httputil'
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. host: app.globalData.host,
  9. busEnterpriseId: null,
  10. xunjianItems: null,
  11. items_first: null,
  12. items_second: null,
  13. items_third: null,
  14. chooseItems: null,
  15. totalItems: 0,
  16. //
  17. isFolded: true,
  18. hui: "block",
  19. currentIndex: 0,
  20. child2: [],
  21. eIndex: 0,
  22. eIndex2: 0,
  23. eIndex3: 0,
  24. selt: "on",
  25. oneL: "",
  26. oneLL: "一类/未选择",
  27. twoL: "二类/未选择",
  28. threeL: "0",
  29. listdatachild: [],
  30. listdatachild2: [],
  31. //未选中图标
  32. noselt: "noNo",
  33. listdata: [{
  34. info: "建立安全防火制度,明确防火责任人及其职责",
  35. checked: true,
  36. },
  37. {
  38. info: "建立安全防火制度,明确防火责任人及其职责,建立安全防火制度,明确防火责任人及其职责,建立安全防火制度,明确防火责任人及其职责",
  39. checked: true,
  40. },
  41. ],
  42. listdata2: [{
  43. info2: "安全出口、疏散指示标识、应急照明是否齐全、有效",
  44. checked: true
  45. },
  46. {
  47. info2: "安全出口、疏散通道应保持通畅,严禁将安全出口上锁、阻塞",
  48. checked: true
  49. },
  50. {
  51. info2: "就餐区内禁止使用液化石油气",
  52. checked: true
  53. },
  54. {
  55. info2: "电气线路严禁斯拉乱按,是否存在低于2米以下电线(电缆)未穿管防护现象",
  56. checked: true
  57. }
  58. ],
  59. listdatachoose: [{
  60. text: "饭点、小饮品店、小超市(食品、药品、水果蔬菜、文具、铁艺制品、生产资料等物资销售)、小诊所检查内容",
  61. children: [{
  62. text: "安全管理",
  63. checked: true,
  64. children: [{
  65. text: "儿贼3级1",
  66. checked: true,
  67. value: '001',
  68. choose: false
  69. },
  70. {
  71. text: "儿贼3级2",
  72. checked: true,
  73. value: '002',
  74. choose: false
  75. }
  76. ],
  77. },
  78. {
  79. text: "现场",
  80. children: [{
  81. text: "儿贼3级1",
  82. checked: true,
  83. value: '003',
  84. choose: false
  85. },
  86. {
  87. text: "儿贼3级2",
  88. checked: false,
  89. value: '004',
  90. choose: false
  91. }
  92. ],
  93. checked: true
  94. }
  95. ]
  96. },
  97. {
  98. text: "小浴池、小网吧、小美容院、小旅馆内容",
  99. children: []
  100. },
  101. {
  102. text: "社会福利业检查内容",
  103. children: []
  104. },
  105. {
  106. text: "建筑工地检查内容",
  107. children: []
  108. },
  109. {
  110. text: "机动车修理铺检查内容",
  111. children: []
  112. },
  113. {
  114. text: "家具制造(床垫)检查内容",
  115. children: []
  116. },
  117. {
  118. text: "食品加工品类检查内容",
  119. children: []
  120. }
  121. ],
  122. listdata5: [{
  123. text: "1、安全出口疏散标识"
  124. },
  125. {
  126. text: "2、就餐区内禁止使用明火"
  127. }
  128. ]
  129. },
  130. onLoad(e) {
  131. this.data.chooseItems = new Map()
  132. this.data.busEnterpriseId = e.busEnterpriseId
  133. this.getXunjianczData()
  134. },
  135. getXunjianczData() {
  136. let obj = new Object();
  137. obj.busEnterpriseId = this.data.busEnterpriseId;
  138. http.post("/system/AppXunjianController/getXunjianczData", obj, this.getXunjianczDataSuccess)
  139. },
  140. getXunjianczDataSuccess(res) {
  141. console.log(res)
  142. this.setData({
  143. xunjianItems: res.xunjianItems,
  144. items_first: res.items_first
  145. })
  146. },
  147. changeme: function (e) {
  148. var flag = e.detail.value;
  149. //flag 为true 代表为选中的状态
  150. if (flag) {
  151. this.setData({
  152. hui: "block"
  153. })
  154. } else {
  155. this.setData({
  156. hui: "hui"
  157. })
  158. }
  159. },
  160. // 切换swiper-item触发bindchange事件
  161. pagechange: function (e) {
  162. // 通过touch判断,改变tab的下标值
  163. if ("touch" === e.detail.source) {
  164. let currentPageIndex = this.data.currentIndex;
  165. currentPageIndex = (currentPageIndex + 1) % 2;
  166. // 拿到当前索引并动态改变
  167. this.setData({
  168. currentIndex: currentPageIndex,
  169. })
  170. }
  171. },
  172. //点击tab时触发
  173. titleClick: function (e) {
  174. this.setData({
  175. //拿到当前索引并动态改变
  176. currentIndex: e.currentTarget.dataset.idx
  177. })
  178. },
  179. change_color_1(e) {
  180. let busitemsid = e.currentTarget.dataset.busitemsid
  181. this.getSecondItems(busitemsid);
  182. // console.log(index)
  183. // console.log(this.data.listdatachoose[index].text)
  184. // let child1 = this.data.listdatachoose[index].text;
  185. this.setData({
  186. myclick: busitemsid,
  187. currentIndex: "1",
  188. // oneLL: child1,
  189. // listdatachild: this.data.listdatachoose[index].children,
  190. twoL: "二类/未选择",
  191. })
  192. // if (this.data.listdatachoose[index].children == '') {
  193. // console.log('null')
  194. // this.setData({
  195. // listdatachild2: ''
  196. // })
  197. // }
  198. },
  199. getSecondItems(busitemsid) {
  200. let obj = new Object();
  201. obj.parentId = busitemsid
  202. http.post("/system/AppXunjianController/getItems", obj, this.getSecondItemsSuccess)
  203. },
  204. getSecondItemsSuccess(res) {
  205. this.setData({
  206. items_second: res.data
  207. })
  208. },
  209. change_color_2(e) {
  210. let busitemsid = e.currentTarget.dataset.busitemsid
  211. this.getThirdItems(busitemsid)
  212. // let index = this.data.eIndex
  213. // let index2 = this.data.eIndex2
  214. // index2 = e.currentTarget.dataset.index2
  215. // let child2 = this.data.listdatachoose[index].children[index2].text
  216. // console.log(this.data.listdatachoose[index].children[index2])
  217. this.setData({
  218. myclick2: busitemsid,
  219. currentIndex: "2",
  220. // listdatachild2: this.data.listdatachoose[index].children[index2].children,
  221. // twoL: child2,
  222. })
  223. },
  224. getThirdItems(busitemsid) {
  225. let obj = new Object();
  226. obj.parentId = busitemsid
  227. obj.busEnterpriseId = this.data.busEnterpriseId
  228. http.post("/system/AppXunjianController/getItemsLast", obj, this.getThirdItemsSuccess)
  229. },
  230. getThirdItemsSuccess(res) {
  231. let that = this
  232. res.data.forEach(element => {
  233. if (that.data.chooseItems[element.busItemsId] == true) {
  234. element.checked = true
  235. }
  236. });
  237. this.setData({
  238. items_third: res.data
  239. })
  240. },
  241. checkThirdItem(e) {
  242. let busItemId = e.currentTarget.dataset.busitemsid
  243. if (this.data.chooseItems[busItemId] == undefined || this.data.chooseItems[busItemId] == null) {
  244. this.data.chooseItems[busItemId] = true
  245. } else {
  246. this.data.chooseItems[busItemId] = null
  247. }
  248. //计数
  249. console.log(this.data.chooseItems)
  250. let count = 0;
  251. for (let item in this.data.chooseItems) {
  252. if (this.data.chooseItems[item] == true) {
  253. count++;
  254. }
  255. }
  256. this.setData({
  257. totalItems: count
  258. })
  259. },
  260. saveXunjianItems() {
  261. let obj = new Object()
  262. obj.busEnterpriseId = this.data.busEnterpriseId
  263. obj.chooseItems = this.data.chooseItems;
  264. http.send_post("/system/AppXunjianController/saveXunjianItems", obj, this.saveXunjianItemsSuccess)
  265. },
  266. saveXunjianItemsSuccess(res) {
  267. console.log(res)
  268. if (res.data.code == 200) {
  269. wx.navigateTo({
  270. url: '../xunjiancz/xunjiancz?busEnterpriseId=' + this.data.busEnterpriseId,
  271. })
  272. }
  273. },
  274. deleteItem(e) {
  275. let that = this
  276. let info = e.currentTarget.dataset.busiteminfo
  277. wx.showModal({
  278. title: "提示",
  279. content: "确定要删除[" + info + "]?",
  280. success: function (sm) {
  281. if(sm.confirm){
  282. let obj = new Object()
  283. obj.busItemsId = e.currentTarget.dataset.busitemid
  284. obj.busEnterpriseId = that.data.busEnterpriseId
  285. obj.jibie = e.currentTarget.dataset.jibie
  286. http.post("/system/AppXunjianController/deleteXunjianItem", obj, that.deleteItemSuccess)
  287. }
  288. }
  289. })
  290. },
  291. deleteItemSuccess(res) {
  292. let that = this
  293. if(res.code ==200){
  294. this.data.xunjianItems[res.data.jibie][1].forEach(function (it,idx) {
  295. console.log(it.listid,"======",res.data.busItemsId)
  296. if(it.listid == res.data.busItemsId){
  297. that.data.xunjianItems[res.data.jibie][1].splice(idx,1)
  298. that.setData({
  299. xunjianItems : that.data.xunjianItems
  300. })
  301. }
  302. })
  303. }
  304. },
  305. bindViewXunJian(){
  306. wx.navigateTo({
  307. url: '../xunjian/xunjian?busEnterpriseId='+this.data.busEnterpriseId,
  308. })
  309. },
  310. change_color_3(e) {
  311. let click = e.currentTarget.dataset.index2
  312. let index = this.data.eIndex
  313. let index2 = this.data.eIndex2
  314. let index3 = this.data.eIndex3
  315. index3 = e.currentTarget.dataset.index3
  316. let child2 = this.data.listdatachoose[index].children[index2].text
  317. console.log(this.data.listdatachoose[index].children[index2])
  318. this.setData({
  319. myclick3: e.currentTarget.dataset.index3,
  320. })
  321. },
  322. checkboxChange(e) {
  323. console.log(e)
  324. // let index = this.data.eIndex
  325. // let index2 = this.data.eIndex2
  326. // console.log('checkbox发生change事件,携带value值为:', e.detail.value)
  327. // const items = this.data.listdatachoose[index].children[index2].children
  328. // console.log(items)
  329. // const values = e.detail.value
  330. // for (let i = 0, lenI = items.length; i < lenI; ++i) {
  331. // items[i].choose = false
  332. // for (let j = 0, lenJ = values.length; j < lenJ; ++j) {
  333. // if (items[i].value === values[j]) {
  334. // items[i].choose = true
  335. // break
  336. // }
  337. // }
  338. // console.log(items[i].choose, 'sladjfklsadjflkasdjflkdjslk')
  339. // }
  340. // this.setData({
  341. // items
  342. // })
  343. },
  344. //收起弹层
  345. updown() {
  346. console.log('弹出收起')
  347. this.setData({
  348. isFolded: !this.data.isFolded,
  349. })
  350. }
  351. })