list.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. <template>
  2. <view class="dynamicModel-list-v">
  3. <view class="head-warp com-dropdown">
  4. <u-dropdown class="u-dropdown" ref="uDropdown">
  5. <u-dropdown-item title="筛选">
  6. <view class="screen-box">
  7. <view class="screen-list" v-if="showParser && columnCondition.length">
  8. <view class="u-p-l-20 u-p-r-20 list">
  9. <scroll-view scroll-y="true" style="height: 100%;">
  10. <Parser :formConf="columnCondition" :searchFormData="searchFormData"
  11. :webType="config.webType" ref="searchForm" @submit="sumbitSearchForm" />
  12. </scroll-view>
  13. </view>
  14. </view>
  15. <view class="notData-box u-flex-col">
  16. <view class="u-flex-col notData-inner">
  17. <image :src="icon" class="iconImg"></image>
  18. <text class="notData-inner-text">{{$t('app.apply.noMoreData')}}</text>
  19. </view>
  20. </view>
  21. <view class="buttom-actions" v-if="showParser && columnCondition.length" style="z-index: 1;">
  22. <u-button class="buttom-btn" @click="reset">{{$t('common.resetText')}}</u-button>
  23. <u-button class="buttom-btn" type="primary"
  24. @click="closeDropdown">{{$t('common.queryText')}}</u-button>
  25. </view>
  26. </view>
  27. </u-dropdown-item>
  28. </u-dropdown>
  29. </view>
  30. <view class="list-warp">
  31. <mescroll-uni ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :up="upOption"
  32. top="164">
  33. <view class="list u-p-b-20 u-p-l-20 u-p-r-20" ref="tableRef">
  34. <view class="list-box">
  35. <uni-swipe-action ref="swipeAction">
  36. <uni-swipe-action-item v-for="(item, index) in list" :key="item.id" :threshold="0"
  37. :disabled="true">
  38. <view class="item" @click="goDetail(item)">
  39. <view class="item-cell" v-for="(column,i) in columnList" :key="i">
  40. <template v-if="column.jnpfKey != 'table'">
  41. <text class="item-cell-label">{{column.label}}:</text>
  42. <text class="item-cell-content"
  43. v-if="['calculate','inputNumber'].includes(column.jnpfKey)">
  44. {{toThousands(item[column.prop],column)}}
  45. </text>
  46. <view class="item-cell-content" v-else-if="column.jnpfKey == 'sign'">
  47. <JnpfSign v-model="item[column.prop]" align="left" detailed />
  48. </view>
  49. <view class="item-cell-content" v-else-if="column.jnpfKey == 'rate'">
  50. <JnpfRate v-model="item[column.prop]" :count="column.count"
  51. :allowHalf="column.allowHalf" disabled />
  52. </view>
  53. <view class="item-cell-content item-cell-slider"
  54. v-else-if="column.jnpfKey == 'slider'">
  55. <JnpfSlider v-model="item[column.prop]" :min="column.min"
  56. :max="column.max" :step="column.step" disabled />
  57. </view>
  58. <view class="item-cell-content" v-else-if="column.jnpfKey == 'input'">
  59. <JnpfInput v-model="item[column.prop]" detailed showOverflow
  60. :useMask="column.useMask" :maskConfig="column.maskConfig"
  61. align='left' />
  62. </view>
  63. <text class="item-cell-content" v-else>{{item[column.prop]}}</text>
  64. </template>
  65. <tableCell v-else @click.stop class="tableCell" ref="tableCell"
  66. :label="column.label" :childList="item[column.prop]"
  67. :children="column.children" :pageLen="3">
  68. </tableCell>
  69. </view>
  70. </view>
  71. </uni-swipe-action-item>
  72. </uni-swipe-action>
  73. </view>
  74. </view>
  75. </mescroll-uni>
  76. </view>
  77. </view>
  78. </template>
  79. <script>
  80. import tableCell from '@/pages/apply/dynamicModel/components/tableCell.vue'
  81. import resources from '@/libs/resources.js'
  82. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  83. import Parser from '@/pages/apply/dynamicModel/components/parser/index.vue'
  84. import {
  85. listLink
  86. } from '@/api/apply/webDesign'
  87. export default {
  88. mixins: [MescrollMixin],
  89. props: ['config', 'modelId', 'columnCondition', 'columnText', 'encryption'],
  90. components: {
  91. Parser,
  92. tableCell
  93. },
  94. data() {
  95. return {
  96. show: false,
  97. icon: resources.message.nodata,
  98. upOption: {
  99. page: {
  100. num: 0,
  101. size: 10,
  102. time: null
  103. },
  104. empty: {
  105. icon: resources.message.nodata,
  106. tip: this.$t('common.noData'),
  107. top: "300rpx"
  108. },
  109. textNoMore: this.$t('app.apply.noMoreData'),
  110. toTop: {
  111. bottom: 250
  112. }
  113. },
  114. list: [],
  115. listQuery: {
  116. sidx: '',
  117. keyword: '',
  118. queryJson: ''
  119. },
  120. options: [{
  121. text: '删除',
  122. style: {
  123. backgroundColor: '#dd524d'
  124. }
  125. }],
  126. showParser: false,
  127. columnList: {},
  128. searchList: [],
  129. searchFormConf: [],
  130. searchFormData: {},
  131. key: +new Date()
  132. }
  133. },
  134. created() {
  135. this.init()
  136. },
  137. methods: {
  138. init() {
  139. this.columnList = this.transformColumnList(this.columnText)
  140. this.columnList.map((o) => {
  141. if (o.jnpfKey != 'table' && o.label.length > 4) {
  142. o.label = o.label.substring(0, 4)
  143. }
  144. })
  145. let config = JSON.parse(this.config.appColumnData)
  146. this.setDefaultQuery(config.defaultSortConfig)
  147. this.$nextTick(() => {
  148. this.key = +new Date()
  149. })
  150. },
  151. setDefaultQuery(defaultSortList) {
  152. const defaultSortConfig = (defaultSortList || []).map(o =>
  153. (o.sort === 'desc' ? '-' : '') + o.field);
  154. this.listQuery.sidx = defaultSortConfig.join(',')
  155. },
  156. toThousands(val, column) {
  157. if (val) {
  158. let valList = val.toString().split('.')
  159. let num = Number(valList[0])
  160. let newVal = column.thousands ? num.toLocaleString() : num
  161. return valList[1] ? newVal + '.' + valList[1] : newVal
  162. } else {
  163. return val
  164. }
  165. },
  166. transformColumnList(columnList) {
  167. let list = []
  168. for (let i = 0; i < columnList.length; i++) {
  169. const e = columnList[i];
  170. if (!e.prop.includes('-')) {
  171. e.option = null
  172. list.push(e)
  173. } else {
  174. let prop = e.prop.split('-')[0]
  175. let vModel = e.prop.split('-')[1]
  176. let label = e.label.split('-')[0]
  177. let childLabel = e.label.replace(label + '-', '');
  178. let newItem = {
  179. align: "center",
  180. jnpfKey: "table",
  181. prop,
  182. label,
  183. children: []
  184. }
  185. e.vModel = vModel
  186. e.childLabel = childLabel
  187. if (!list.some(o => o.prop === prop)) list.push(newItem)
  188. for (let i = 0; i < list.length; i++) {
  189. if (list[i].prop === prop) {
  190. e.option = null
  191. list[i].children.push(e)
  192. break
  193. }
  194. }
  195. }
  196. }
  197. return list
  198. },
  199. upCallback(page) {
  200. if (this.isPreview == '1') return this.mescroll.endSuccess(0, false);
  201. const query = {
  202. currentPage: page.num,
  203. pageSize: page.size,
  204. menuId: this.modelId,
  205. ...this.listQuery
  206. }
  207. listLink(this.modelId, query, this.encryption, {
  208. load: page.num == 1
  209. }, this.encryption).then(res => {
  210. this.showParser = true
  211. if (page.num == 1) this.list = [];
  212. this.mescroll.endSuccess(res.data.list.length);
  213. const list = res.data.list.map((o, i) => ({
  214. show: false,
  215. ...o
  216. }));
  217. this.list = this.list.concat(list);
  218. uni.$off('refresh')
  219. }).catch((err) => {
  220. this.mescroll.endByPage(0, 0);
  221. this.mescroll.endErr();
  222. uni.$off('refresh')
  223. })
  224. },
  225. goDetail(item) {
  226. if (!item.id) return
  227. let config = {
  228. modelId: this.modelId,
  229. id: item.id,
  230. formTitle: '详情',
  231. noShowBtn: 1,
  232. encryption: this.encryption
  233. }
  234. this.$nextTick(() => {
  235. const url = `./detail?config=${this.jnpf.base64.encode(JSON.stringify(config),"UTF-8")}`
  236. uni.navigateTo({
  237. url: url
  238. })
  239. })
  240. },
  241. reset() {
  242. this.searchFormData = {}
  243. const list = ['datePicker', 'timePicker', 'inputNumber', 'calculate', 'cascader', 'organizeSelect']
  244. for (let i = 0; i < this.searchList.length; i++) {
  245. const item = this.searchList[i]
  246. const config = item.__config__
  247. let defaultValue = item.searchMultiple || list.includes(config.jnpfKey) ? [] : undefined
  248. config.defaultValue = defaultValue
  249. this.searchFormData[item.__vModel__] = defaultValue
  250. }
  251. this.searchFormConf = JSON.parse(JSON.stringify(this.searchList))
  252. },
  253. closeDropdown() {
  254. if (this.isPreview == '1') return this.$u.toast('功能预览不支持检索')
  255. this.$refs.searchForm && this.$refs.searchForm.submitForm()
  256. },
  257. fillFormData(list, data) {
  258. for (let i = 0; i < list.length; i++) {
  259. let item = list[i]
  260. const val = data.hasOwnProperty(item.__vModel__) ? data[item.__vModel__] : item.__config__
  261. .defaultValue
  262. if (!item.__config__.custom && item.__config__.defaultCurrent && item.__config__
  263. .jnpfKey === 'timePicker') val = this.jnpf.toDate(new Date(), item.format)
  264. if (!item.__config__.custom && item.__config__.defaultCurrent && item.__config__
  265. .jnpfKey === 'datePicker') val = new Date().getTime()
  266. item.__config__.defaultValue = val
  267. }
  268. },
  269. sumbitSearchForm(data) {
  270. const queryJson = data || {}
  271. this.searchFormData = data
  272. this.listQuery.queryJson = JSON.stringify(queryJson) !== '{}' ? JSON.stringify(queryJson) : ''
  273. this.$refs.uDropdown.close();
  274. this.$nextTick(() => {
  275. this.list = [];
  276. this.mescroll.resetUpScroll();
  277. })
  278. }
  279. }
  280. }
  281. </script>
  282. <style lang="scss">
  283. page {
  284. background-color: #f0f2f6;
  285. height: 100%;
  286. /* #ifdef MP-ALIPAY */
  287. position: absolute;
  288. top: 0;
  289. left: 0;
  290. width: 100%;
  291. /* #endif */
  292. }
  293. .item {
  294. padding: 0 !important;
  295. }
  296. .notData-box {
  297. width: 100%;
  298. height: 100%;
  299. justify-content: center;
  300. align-items: center;
  301. padding-bottom: 200rpx;
  302. .notData-inner {
  303. width: 280rpx;
  304. height: 308rpx;
  305. align-items: center;
  306. .iconImg {
  307. width: 100%;
  308. height: 100%;
  309. }
  310. .notData-inner-text {
  311. padding: 30rpx 0;
  312. color: #909399;
  313. }
  314. }
  315. }
  316. .screen-box {
  317. background-color: #fff;
  318. height: 100%;
  319. .screen-list {
  320. width: 100%;
  321. height: 100%;
  322. .list {
  323. height: calc(100% - 88rpx);
  324. overflow-y: scroll;
  325. }
  326. }
  327. }
  328. </style>