xunjiancz.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  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: false,
  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. this.setData({
  142. xunjianItems: res.xunjianItems,
  143. items_first: res.items_first
  144. })
  145. },
  146. changeme: function (e) {
  147. var flag = e.detail.value;
  148. //flag 为true 代表为选中的状态
  149. if (flag) {
  150. this.setData({
  151. hui: "block"
  152. })
  153. } else {
  154. this.setData({
  155. hui: "hui"
  156. })
  157. }
  158. },
  159. // 切换swiper-item触发bindchange事件
  160. pagechange: function (e) {
  161. // 通过touch判断,改变tab的下标值
  162. if ("touch" === e.detail.source) {
  163. let currentPageIndex = this.data.currentIndex;
  164. currentPageIndex = (currentPageIndex + 1) % 2;
  165. // 拿到当前索引并动态改变
  166. this.setData({
  167. currentIndex: currentPageIndex,
  168. })
  169. }
  170. },
  171. //点击tab时触发
  172. titleClick: function (e) {
  173. this.setData({
  174. //拿到当前索引并动态改变
  175. currentIndex: e.currentTarget.dataset.idx
  176. })
  177. },
  178. change_color_1(e) {
  179. let busitemsid = e.currentTarget.dataset.busitemsid
  180. this.getSecondItems(busitemsid);
  181. // console.log(index)
  182. // console.log(this.data.listdatachoose[index].text)
  183. // let child1 = this.data.listdatachoose[index].text;
  184. this.setData({
  185. myclick: busitemsid,
  186. currentIndex: "1",
  187. // oneLL: child1,
  188. // listdatachild: this.data.listdatachoose[index].children,
  189. twoL: "二类/未选择",
  190. })
  191. // if (this.data.listdatachoose[index].children == '') {
  192. // console.log('null')
  193. // this.setData({
  194. // listdatachild2: ''
  195. // })
  196. // }
  197. },
  198. getSecondItems(busitemsid) {
  199. let obj = new Object();
  200. obj.parentId = busitemsid
  201. http.post("/system/AppXunjianController/getItems", obj, this.getSecondItemsSuccess)
  202. },
  203. getSecondItemsSuccess(res) {
  204. this.setData({
  205. items_second: res.data
  206. })
  207. },
  208. change_color_2(e) {
  209. let busitemsid = e.currentTarget.dataset.busitemsid
  210. this.getThirdItems(busitemsid)
  211. // let index = this.data.eIndex
  212. // let index2 = this.data.eIndex2
  213. // index2 = e.currentTarget.dataset.index2
  214. // let child2 = this.data.listdatachoose[index].children[index2].text
  215. // console.log(this.data.listdatachoose[index].children[index2])
  216. this.setData({
  217. myclick2: busitemsid,
  218. currentIndex: "2",
  219. // listdatachild2: this.data.listdatachoose[index].children[index2].children,
  220. // twoL: child2,
  221. })
  222. },
  223. getThirdItems(busitemsid) {
  224. let obj = new Object();
  225. obj.parentId = busitemsid
  226. obj.busEnterpriseId = this.data.busEnterpriseId
  227. http.post("/system/AppXunjianController/getItemsLast", obj, this.getThirdItemsSuccess)
  228. },
  229. getThirdItemsSuccess(res) {
  230. let that = this
  231. res.data.forEach(element => {
  232. if (that.data.chooseItems[element.busItemsId] == true) {
  233. element.checked = true
  234. }
  235. });
  236. this.setData({
  237. items_third: res.data
  238. })
  239. },
  240. checkThirdItem(e) {
  241. let busItemId = e.currentTarget.dataset.busitemsid
  242. if (this.data.chooseItems[busItemId] == undefined || this.data.chooseItems[busItemId] == null) {
  243. this.data.chooseItems[busItemId] = true
  244. } else {
  245. this.data.chooseItems[busItemId] = null
  246. }
  247. //计数
  248. let count = 0;
  249. for (let item in this.data.chooseItems) {
  250. if (this.data.chooseItems[item] == true) {
  251. count++;
  252. }
  253. }
  254. this.setData({
  255. totalItems: count
  256. })
  257. },
  258. saveXunjianItems() {
  259. let obj = new Object()
  260. obj.busEnterpriseId = this.data.busEnterpriseId
  261. obj.chooseItems = this.data.chooseItems;
  262. http.send_post("/system/AppXunjianController/saveXunjianItems", obj, this.saveXunjianItemsSuccess)
  263. this.updown();
  264. },
  265. saveXunjianItemsSuccess(res) {
  266. if (res.code == 200) {
  267. // wx.navigateTo({
  268. // url: '../xunjiancz/xunjiancz?busEnterpriseId=' + this.data.busEnterpriseId,
  269. // })
  270. let e = new Object()
  271. e.busEnterpriseId = this.data.busEnterpriseId
  272. this.onLoad(e);
  273. }
  274. },
  275. deleteItem(e) {
  276. let that = this
  277. let info = e.currentTarget.dataset.busiteminfo
  278. wx.showModal({
  279. title: "提示",
  280. content: "确定要删除[" + info + "]?",
  281. success: function (sm) {
  282. if(sm.confirm){
  283. let obj = new Object()
  284. obj.busItemsId = e.currentTarget.dataset.busitemid
  285. obj.busEnterpriseId = that.data.busEnterpriseId
  286. obj.jibie = e.currentTarget.dataset.jibie
  287. http.post("/system/AppXunjianController/deleteXunjianItem", obj, that.deleteItemSuccess)
  288. }
  289. }
  290. })
  291. },
  292. deleteItemSuccess(res) {
  293. let that = this
  294. if(res.code ==200){
  295. this.data.xunjianItems[res.data.jibie][1].forEach(function (it,idx) {
  296. if(it.listid == res.data.busItemsId){
  297. that.data.xunjianItems[res.data.jibie][1].splice(idx,1)
  298. if(that.data.xunjianItems[res.data.jibie][1].length==0){
  299. delete that.data.xunjianItems[res.data.jibie]
  300. }
  301. that.setData({
  302. xunjianItems : that.data.xunjianItems
  303. })
  304. }
  305. })
  306. }
  307. },
  308. bindViewXunJian(){
  309. let page = getCurrentPages();
  310. let prevPage = page[page.length - 2];
  311. prevPage.setData({
  312. isAfterBack :true,
  313. });
  314. wx.navigateBack()
  315. },
  316. onUnload:function(){
  317. let page = getCurrentPages();
  318. let prevPage = page[page.length - 2];
  319. prevPage.setData({
  320. isAfterBack :true,
  321. });
  322. },
  323. change_color_3(e) {
  324. let click = e.currentTarget.dataset.index2
  325. let index = this.data.eIndex
  326. let index2 = this.data.eIndex2
  327. let index3 = this.data.eIndex3
  328. index3 = e.currentTarget.dataset.index3
  329. let child2 = this.data.listdatachoose[index].children[index2].text
  330. this.setData({
  331. myclick3: e.currentTarget.dataset.index3,
  332. })
  333. },
  334. checkboxChange(e) {
  335. // let index = this.data.eIndex
  336. // let index2 = this.data.eIndex2
  337. // console.log('checkbox发生change事件,携带value值为:', e.detail.value)
  338. // const items = this.data.listdatachoose[index].children[index2].children
  339. // console.log(items)
  340. // const values = e.detail.value
  341. // for (let i = 0, lenI = items.length; i < lenI; ++i) {
  342. // items[i].choose = false
  343. // for (let j = 0, lenJ = values.length; j < lenJ; ++j) {
  344. // if (items[i].value === values[j]) {
  345. // items[i].choose = true
  346. // break
  347. // }
  348. // }
  349. // console.log(items[i].choose, 'sladjfklsadjflkasdjflkdjslk')
  350. // }
  351. // this.setData({
  352. // items
  353. // })
  354. },
  355. //收起弹层
  356. updown() {
  357. this.setData({
  358. isFolded: !this.data.isFolded,
  359. })
  360. }
  361. })