index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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. >
  47. <div class="cell_1">
  48. <div class="width100 height44rpx mb16rpx">
  49. <div class="first_title">{{ getDicType(item.type) }}</div>
  50. </div>
  51. <div class="width100 height40rpx">
  52. <div class="second_title" style="width: 100%">
  53. {{ item.companyName }} {{ " " + item.createdAt }}
  54. </div>
  55. </div>
  56. </div>
  57. <img
  58. src="../../../static/mine/youjiantou.png"
  59. style="width: 100rpx; height: 100rpx"
  60. alt=""
  61. />
  62. </div>
  63. <!-- </div> -->
  64. <!-- <div v-else> -->
  65. <van-empty
  66. v-if="companyList.length == 0"
  67. class="disblock marginauto"
  68. style="background: white"
  69. description="暂无数据"
  70. />
  71. <!-- </div> -->
  72. </div>
  73. </div>
  74. </template>
  75. <script>
  76. import { findSafetySelfCheckingManageList, getByCodes } from "@/js_sdk/http";
  77. import vanEmpty from "../../../wxcomponents/weapp/dist/empty/index";
  78. export default {
  79. components: {
  80. vanEmpty,
  81. },
  82. data() {
  83. return {
  84. dic_key: ["safety_inspection_type"],
  85. dic_SelectList: {},
  86. active: 0,
  87. form: {
  88. attributiveYear: "2023",
  89. },
  90. statusList: [
  91. { label: "全部", value: null },
  92. { label: "电梯自检", value: "1" },
  93. { label: "消防自检", value: "2" },
  94. { label: "电柜检查", value: "3" },
  95. { label: "电器线路", value: "4" },
  96. ],
  97. companyList: [],
  98. search: {
  99. pageSize: 10,
  100. pageNum: 1,
  101. attributiveYear: "2023",
  102. },
  103. };
  104. },
  105. onShow() {
  106. // this.getByCodes();
  107. this.getByCodes();
  108. },
  109. methods: {
  110. getDicType(value) {
  111. if (!value) return "未知类型";
  112. let safety_inspection_type = this.dic_SelectList.safety_inspection_type;
  113. let index = safety_inspection_type.findIndex((e) => e.value == value);
  114. return safety_inspection_type[index].label;
  115. },
  116. bindDateChange(event) {
  117. this.search.attributiveYear = event.detail.value;
  118. this.getCompanyList();
  119. this.$forceUpdate();
  120. },
  121. junmpMyMechantsDetails(id) {
  122. uni.navigateTo({
  123. url: "/pages/subPackages/secureselftest/report?id=" + id,
  124. });
  125. },
  126. jumpReport() {
  127. uni.navigateTo({
  128. url: "/pages/subPackages/secureselftest/report?id=" + null,
  129. });
  130. },
  131. async getMoreListData() {
  132. let that = this;
  133. that.search.pageNum = that.search.pageNum + 1;
  134. let list = await findSafetySelfCheckingManageList(that.search);
  135. if (list.rows == 0) {
  136. that.$showToast("没有更多数据了");
  137. } else {
  138. list.rows.forEach((e) => {
  139. that.companyList.push(e);
  140. });
  141. }
  142. },
  143. onReachBottom() {
  144. this.getMoreListData();
  145. }, //下拉执行的时候触发 (下拉刷新)
  146. onChange(e) {
  147. this.search.type = e.detail.name == null ? "" : e.detail.name;
  148. this.getCompanyList();
  149. },
  150. endDate() {
  151. return this.getDate("end");
  152. },
  153. startDate() {
  154. return this.getDate("start");
  155. },
  156. async getByCodes() {
  157. let data = await getByCodes(JSON.stringify(this.dic_key));
  158. this.dic_SelectList = this.$common.handleDicList(data);
  159. this.getCompanyList();
  160. },
  161. getDate(type) {
  162. const date = new Date();
  163. let year = date.getFullYear();
  164. let month = date.getMonth() + 1;
  165. let day = date.getDate();
  166. if (type === "start") {
  167. year = year - 60;
  168. } else if (type === "end") {
  169. year = year + 2;
  170. }
  171. month = month > 9 ? month : "0" + month;
  172. day = day > 9 ? day : "0" + day;
  173. return `${year}-${month}-${day}`;
  174. },
  175. async getCompanyList() {
  176. this.search.pageSize = 10;
  177. this.search.pageNum = 1;
  178. let list = await findSafetySelfCheckingManageList(this.search);
  179. // /wx/SafetyController/findSafetySelfCheckingManageList
  180. list.rows.forEach((e) => {
  181. e.createdAt = this.$common.transDate(e.createdAt);
  182. });
  183. this.companyList = list.rows;
  184. },
  185. jumpAddCompanyPage() {
  186. uni.navigateTo({
  187. url: "/pages/subPackages/addCompany/addCompany",
  188. });
  189. },
  190. jumpPage(e) {
  191. uni.navigateTo({
  192. url: "/pages/subPackages/companyDetails/companyDetails?id=" + e,
  193. });
  194. },
  195. },
  196. };
  197. </script>
  198. <style lang="scss">
  199. .chooseyears {
  200. width: 326rpx;
  201. height: 56rpx;
  202. background: rgba(29, 24, 188, 0.05);
  203. border-radius: 8rpx 8rpx 8rpx 8rpx;
  204. text-align: center;
  205. line-height: 56rpx;
  206. color: #1d18bc;
  207. }
  208. .searchbox {
  209. display: block;
  210. background: white;
  211. }
  212. .chaochuyincang {
  213. white-space: nowrap;
  214. overflow: hidden;
  215. text-overflow: ellipsis;
  216. }
  217. .secureselftest {
  218. .van-tab {
  219. // flex: none !important;
  220. // margin: 0 32rpx;
  221. }
  222. .custom-class {
  223. background: white;
  224. }
  225. }
  226. </style>