list.vue 9.5 KB

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