list.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <template>
  2. <view class="enterprise-list">
  3. <view class="list-wrap">
  4. <u-sticky bgColor="#fff" class="main-sticky">
  5. <view class="search-wrap">
  6. <view class="input-wrap">
  7. <view class="input search">
  8. <u-search bgColor='#fff' :showAction='false'
  9. :placeholder="$t('base.common.inputPlaceholder')" @search="searchList"
  10. @clear='searchList' v-model="form.keyword">
  11. </u-search>
  12. <view class="sx-btn" @click="searchList">{{ $t("customer_meter.search") }}</view>
  13. </view>
  14. </view>
  15. </view>
  16. <view class="tabs-box">
  17. <!-- <u-subsection :list="statusList" mode="subsection" fontSize="30rpx" activeColor="rgb(60, 156, 255)"
  18. :current="statusActive" @change="onChangeStatus">
  19. </u-subsection> -->
  20. <u-tabs lineWidth="40" :list="statusList" :current="statusActive" @change="onChangeStatus"
  21. lineColor="#3275F5" :itemStyle="{ 'height': '90rpx', 'padding': '0 32rpx' }">
  22. </u-tabs>
  23. </view>
  24. </u-sticky>
  25. <template v-if="tenantList.length">
  26. <view class="business-card" v-for="(item, index) in tenantList" :key="index">
  27. <view class="title">{{ item.tenantName || '' }}</view>
  28. <view class="business-card-info">
  29. <view class="info-line">
  30. <text class="label">{{ $t('customer_meter.tenantCode') }}</text>
  31. <text class="info">{{ item.tenantCode || '' }}</text>
  32. </view>
  33. <view class="businessStatus-info">
  34. <u--image width="100rpx" height="88rpx" v-if="item.statusFlag == 2"
  35. src="/subpages/static/czzn-img/state/not-audit.png"></u--image>
  36. <u--image width="100rpx" height="88rpx" v-if="item.statusFlag == 3"
  37. src="/subpages/static/czzn-img/state/no-pass-audit.png"></u--image>
  38. <u--image width="100rpx" height="88rpx" v-if="item.statusFlag == 0"
  39. src="/subpages/static/czzn-img/state/stop.png" @click="onUpdateStatus(item)"></u--image>
  40. <u--image width="100rpx" height="88rpx" v-if="item.statusFlag == 1"
  41. src="/subpages/static/czzn-img/state/start.png"
  42. @click="onUpdateStatus(item)"></u--image>
  43. </view>
  44. </view>
  45. <view v-if="isDealerUser==true">
  46. <u-line></u-line>
  47. <view class="business-card-append"
  48. v-for="tenantVehicleType in vehicleTypeList.filter((p) => { return p.tenantId == item.tenantId })"
  49. :key="tenantVehicleType.tenantId">
  50. <template v-if="tenantVehicleType.vehicleTypeList.length">
  51. <view class="btn" v-for="vehicleType in tenantVehicleType.vehicleTypeList"
  52. :key="vehicleType.value">
  53. <button class="oper-btn bule"
  54. @click="toCompanyList(item.tenantId, vehicleType.value)">
  55. {{ vehicleType.text }}
  56. </button>
  57. </view>
  58. </template>
  59. <template v-else>
  60. <u-tag text="未分配业务" size="mini" type="error"></u-tag>
  61. </template>
  62. </view>
  63. </view>
  64. </view>
  65. </template>
  66. <template v-else>
  67. <view class="data-empty">
  68. <image src="/subpages/static/czzn-img/empty.png" mode="widthFix" style="width:100%" />
  69. <text class="empty-text">{{$t('base.common.noData')}}</text>
  70. </view>
  71. </template>
  72. <!-- <uni-fab ref="fab" buttonColor="#3c9cff" @trigger="trigger" @fabClick="onClickRight" /> -->
  73. </view>
  74. <u-modal :show="showAdd" @confirm="onApplyTenant" ref="addModal" showCancelButton closeOnClickOverlay
  75. @cancel="showAdd = false" @close="showAdd = false" stlye="z-index:-1">
  76. <view class="invite-box">
  77. <u--input :placeholder="$t('base.common.PleaseEnterTheBusinessNumber')" border="surround"
  78. v-model="tenantCode" @blur="tenantBlur()"></u--input>
  79. <u--text :text="tenantName"></u--text>
  80. </view>
  81. </u-modal>
  82. </view>
  83. </template>
  84. <script>
  85. import {
  86. getDealerTenantList,
  87. applyTenant,
  88. updateStatus,
  89. getTenantByCode
  90. } from "../../api/tenant.js";
  91. export default {
  92. data() {
  93. return {
  94. current: undefined,
  95. showAdd: false,
  96. form: {
  97. keyword: "",
  98. statusFlag: ""
  99. },
  100. showConfirm:false,
  101. value: "",
  102. statusActive: 0,
  103. tenantCode: "",
  104. tenantName: "",
  105. isDealerUser: false,
  106. tenantList: [],
  107. vehicleTypeList: [],
  108. statusList: [{
  109. name: this.$t("customer_meter.all"),
  110. statusFlag: ''
  111. },
  112. {
  113. name: this.$t("customer_meter.enable"),
  114. statusFlag: '1'
  115. },
  116. {
  117. name: this.$t("customer_meter.deactivate"),
  118. statusFlag: '0'
  119. },
  120. {
  121. name: this.$t("customer_meter.audit"),
  122. statusFlag: '2'
  123. },
  124. ],
  125. };
  126. },
  127. components: {},
  128. onLoad(options) {
  129. this.bindTenant();
  130. if (options.q && options.q == "add") {
  131. this.showAdd = true;
  132. }
  133. this.isDealerUser = uni.getStorageSync('isDealerUser')
  134. },
  135. methods: {
  136. tenantBlur() {
  137. var that = this;
  138. if (!that.tenantCode) {
  139. uni.showToast({
  140. title: this.$t('tenant.tenantCode'),
  141. icon: "none",
  142. duration: 2500,
  143. })
  144. return;
  145. }
  146. getTenantByCode(that.tenantCode).then((res) => {
  147. console.log("获取到的租户信息,", res);
  148. if (res.statusCode == 200 && res.data.code == 0) {
  149. uni.showModal({
  150. // title: '提示',
  151. content: that.$t("tenant.bindTenant") + "【" + res.data.data.name + "】",
  152. showCancel: true,
  153. cancelText: that.$t("base.button.goBack"),
  154. confirmText: that.$t("base.button.submit"),
  155. success: function(res) {
  156. if (res.confirm) {
  157. console.log('用户点击确定');
  158. that.showConfirm=true;
  159. that.onApplyTenant();
  160. } else if (res.cancel) {
  161. console.log('用户点击取消');
  162. that.showAdd = false
  163. that.showConfirm=false;
  164. that.tenantCode = ""
  165. }
  166. }
  167. })
  168. }
  169. }).catch((res) => {
  170. that.showAdd = false
  171. });
  172. },
  173. //跳转到企业下客商列表
  174. toCompanyList(tenantId, vehicleType) {
  175. uni.navigateTo({
  176. url: `/subpages/tenant/companyInfo?tenantId=${tenantId}&vehicleType=${vehicleType}`,
  177. })
  178. },
  179. //搜索列表
  180. searchList() {
  181. this.bindTenant()
  182. },
  183. //显示启用弹窗
  184. onUpdateStatus(item) {
  185. var that = this;
  186. wx.showModal({
  187. content: (item.statusFlag == '1' ? that.$t('tenant.stopTenant') : that.$t(
  188. 'tenant.startTenant')),
  189. showCancel: true,
  190. success: function(res) {
  191. if (res.confirm) {
  192. updateStatus(item.id, (item.statusFlag == '1' ? '0' : '1')).then(res => {
  193. if (res.statusCode == 200) {
  194. uni.showToast({
  195. title: that.$t("base.common.complete"),
  196. icon: "none",
  197. duration: 2000,
  198. });
  199. that.bindTenant()
  200. }
  201. })
  202. console.log('用户点击确定');
  203. } else {
  204. }
  205. }
  206. })
  207. },
  208. bindTenant() {
  209. var that = this;
  210. getDealerTenantList(this.form).then((res) => {
  211. if (res.statusCode == 200) {
  212. that.tenantList = res.data.data;
  213. uni.removeStorageSync('tenantInfo')
  214. uni.setStorageSync('tenantInfo', that.tenantList)
  215. that.vehicleTypeList = [];
  216. that.tenantList.forEach(tenant => {
  217. that.vehicleTypeList.push({
  218. "tenantId": tenant.tenantId,
  219. "vehicleTypeList": uni.getStorageSync('vehicleType-' + tenant
  220. .tenantId)
  221. });
  222. });
  223. console.log("获取到租户对应的业务信息、", that.vehicleTypeList);
  224. }
  225. });
  226. },
  227. //点击右侧加号
  228. onClickRight() {
  229. this.showAdd = true;
  230. },
  231. onChangeStatus(item) {
  232. this.statusActive = item.index
  233. var statusFlag = this.statusList[item.index].statusFlag;
  234. if (this.form.statusFlag == statusFlag) {
  235. return
  236. } else {
  237. this.form.statusFlag = statusFlag;
  238. this.bindTenant()
  239. }
  240. },
  241. //绑定企业
  242. onApplyTenant() {
  243. var that = this;
  244. if(!that.showConfirm){
  245. return;
  246. }
  247. console.log("企业编码:",that.tenantCode);
  248. applyTenant(that.tenantCode).then((res) => {
  249. that.tenantCode = ""
  250. that.showAdd = false
  251. if (res.statusCode == 200 && res.data.code == 0) {
  252. uni.showToast({
  253. title: that.$t("base.common.complete"),
  254. icon: "none",
  255. duration: 2000,
  256. });
  257. that.bindTenant();
  258. }
  259. that.showConfirm=false;
  260. });
  261. },
  262. },
  263. };
  264. </script>
  265. <style>
  266. /* #ifndef APP-NVUE */
  267. view {
  268. box-sizing: border-box;
  269. }
  270. page {
  271. background-color: #f5f7fa;
  272. }
  273. /* #endif */
  274. </style>
  275. <style lang="scss" scoped>
  276. @import '../../common/css/public.scss';
  277. </style>