index.vue 6.4 KB

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