index.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <template>
  2. <div class="secureselftest">
  3. <van-tabs :swipe-threshold="3" :active="active" @change="onChange">
  4. <van-tab title="全部" :name="null"></van-tab>
  5. <van-tab
  6. :title="item.label"
  7. :name="item.value"
  8. :key="item.id"
  9. v-for="item in dic_SelectList.safety_inspection_type"
  10. ></van-tab>
  11. </van-tabs>
  12. <div class="searchbox" style="padding-bottom: 15rpx">
  13. <van-row style="background: white">
  14. <van-col :span="15">
  15. <picker
  16. class="ml32 mt10"
  17. mode="date"
  18. :value="form.year"
  19. fields="year"
  20. :start="startDate"
  21. :end="endDate"
  22. @change="bindDateChange"
  23. >
  24. <div class="chooseyears">
  25. <div style="margin-left: 16rpx; width: auto; float: left">
  26. {{ search.attributiveYear + "年" }}
  27. </div>
  28. <van-icon
  29. name="arrow-down"
  30. style="float: right; margin-top: 11rpx"
  31. />
  32. </div>
  33. </picker>
  34. </van-col>
  35. <van-col :span="8"> </van-col>
  36. </van-row>
  37. </div>
  38. <div class="list">
  39. <!-- <div v-if="companyList.length == 0"> -->
  40. <div
  41. class="list-row"
  42. v-if="companyList.length != 0"
  43. v-for="(item, index) in companyList"
  44. @click="junmpMyMechantsDetails(item.id)"
  45. :key="index"
  46. style="position: relative"
  47. >
  48. <div
  49. class="statusBox"
  50. :style="{
  51. background:
  52. !item.handlingFeedback || item.handlingFeedback.length == 0
  53. ? 'rgba(255, 180, 32,0.8)'
  54. : 'rgba(0, 128, 0,0.8)',
  55. }"
  56. >
  57. {{
  58. !item.handlingFeedback || item.handlingFeedback.length == 0
  59. ? "待反馈"
  60. : "已反馈"
  61. }}
  62. </div>
  63. <div class="cell_1">
  64. <div class="width100 height44rpx mb16rpx">
  65. <div class="first_title">
  66. {{ getDicType(item.type) }}
  67. </div>
  68. </div>
  69. <div class="width100 height40rpx">
  70. <div class="second_title" style="width: 100%">
  71. {{ item.companyName }} {{ " " + item.createdAt }}
  72. </div>
  73. </div>
  74. </div>
  75. </div>
  76. <!-- </div> -->
  77. <!-- <div v-else> -->
  78. <van-empty
  79. v-if="companyList.length == 0"
  80. class="disblock marginauto"
  81. style="background: white"
  82. description="暂无数据"
  83. />
  84. <!-- </div> -->
  85. </div>
  86. </div>
  87. </template>
  88. <script>
  89. import { findSafetySelfCheckingManageList, getByCodes } from "@/js_sdk/http";
  90. import vanEmpty from "../../../wxcomponents/weapp/dist/empty/index";
  91. export default {
  92. components: {
  93. vanEmpty,
  94. },
  95. data() {
  96. return {
  97. dic_key: ["safety_inspection_type"],
  98. dic_SelectList: {},
  99. active: 0,
  100. form: {
  101. attributiveYear: "2024",
  102. },
  103. statusList: [
  104. { label: "全部", value: null },
  105. { label: "电梯自检", value: "1" },
  106. { label: "消防自检", value: "2" },
  107. { label: "电柜检查", value: "3" },
  108. { label: "电器线路", value: "4" },
  109. ],
  110. companyList: [],
  111. search: {
  112. pageSize: 10,
  113. pageNum: 1,
  114. attributiveYear: "2024",
  115. },
  116. };
  117. },
  118. onShow() {
  119. // this.getByCodes();
  120. this.getByCodes();
  121. },
  122. methods: {
  123. getDicType(value) {
  124. console.log(this.dic_SelectList.safety_inspection_type);
  125. if (!value) return "未知类型";
  126. if (
  127. !this.dic_SelectList.safety_inspection_type ||
  128. this.dic_SelectList.safety_inspection_type.length == 0
  129. )
  130. return;
  131. let safety_inspection_type = this.dic_SelectList.safety_inspection_type;
  132. let index = safety_inspection_type.findIndex((e) => e.value == value);
  133. console.log(index);
  134. if (index != -1) return safety_inspection_type[index].label;
  135. },
  136. bindDateChange(event) {
  137. this.search.attributiveYear = event.detail.value;
  138. this.getCompanyList();
  139. this.$forceUpdate();
  140. },
  141. junmpMyMechantsDetails(id) {
  142. uni.navigateTo({
  143. url:
  144. "/pages/subPackages/secureselftest/report?id=" +
  145. id +
  146. "&saveBtnStatus=" +
  147. true,
  148. });
  149. },
  150. jumpReport() {
  151. uni.navigateTo({
  152. url:
  153. "/pages/subPackages/secureselftest/report?id=" +
  154. null +
  155. "&saveBtnStatus=" +
  156. true,
  157. });
  158. },
  159. async getMoreListData() {
  160. let that = this;
  161. that.search.pageNum = that.search.pageNum + 1;
  162. let list = await findSafetySelfCheckingManageList(that.search);
  163. if (list.rows == 0) {
  164. that.$showToast("没有更多数据了");
  165. } else {
  166. list.rows.forEach((e) => {
  167. that.companyList.push(e);
  168. });
  169. }
  170. },
  171. onReachBottom() {
  172. console.log("getMoreListData");
  173. this.getMoreListData();
  174. }, //下拉执行的时候触发 (下拉刷新)
  175. onChange(e) {
  176. this.search.type = e.detail.name == null ? "" : e.detail.name;
  177. this.getCompanyList();
  178. },
  179. endDate() {
  180. return this.getDate("end");
  181. },
  182. startDate() {
  183. return this.getDate("start");
  184. },
  185. async getByCodes() {
  186. let data = await getByCodes(JSON.stringify(this.dic_key));
  187. this.dic_SelectList = this.$common.handleDicList(data);
  188. this.getCompanyList();
  189. },
  190. getDate(type) {
  191. const date = new Date();
  192. let year = date.getFullYear();
  193. let month = date.getMonth() + 1;
  194. let day = date.getDate();
  195. if (type === "start") {
  196. year = year - 60;
  197. } else if (type === "end") {
  198. year = year + 2;
  199. }
  200. month = month > 9 ? month : "0" + month;
  201. day = day > 9 ? day : "0" + day;
  202. return `${year}-${month}-${day}`;
  203. },
  204. async getCompanyList() {
  205. this.search.pageSize = 10;
  206. this.search.pageNum = 1;
  207. let list = await findSafetySelfCheckingManageList(this.search);
  208. // /wx/SafetyController/findSafetySelfCheckingManageList
  209. list.rows.forEach((e) => {
  210. e.createdAt = this.$common.transDate(e.createdAt);
  211. });
  212. this.companyList = list.rows;
  213. },
  214. jumpAddCompanyPage() {
  215. uni.navigateTo({
  216. url: "/pages/subPackages/addCompany/addCompany",
  217. });
  218. },
  219. jumpPage(e) {
  220. uni.navigateTo({
  221. url: "/pages/subPackages/companyDetails/companyDetails?id=" + e,
  222. });
  223. },
  224. },
  225. };
  226. </script>
  227. <style lang="scss">
  228. .chooseyears {
  229. width: 326rpx;
  230. height: 56rpx;
  231. background: rgba(29, 24, 188, 0.05);
  232. border-radius: 8rpx 8rpx 8rpx 8rpx;
  233. text-align: center;
  234. line-height: 56rpx;
  235. color: #1d18bc;
  236. }
  237. .searchbox {
  238. display: block;
  239. background: white;
  240. }
  241. .chaochuyincang {
  242. white-space: nowrap;
  243. overflow: hidden;
  244. text-overflow: ellipsis;
  245. }
  246. .secureselftest {
  247. .van-tab {
  248. // flex: none !important;
  249. // margin: 0 32rpx;
  250. }
  251. .custom-class {
  252. background: white;
  253. }
  254. }
  255. .statusBox {
  256. background: black;
  257. color: white;
  258. width: 105rpx;
  259. padding: 10rpx;
  260. text-align: center;
  261. position: absolute;
  262. top: 0;
  263. right: 0;
  264. }
  265. </style>