index.vue.vm 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869
  1. #parse("PublicMacro/AppFormMarco.vm")
  2. <template>
  3. <view class="dynamicModel-list-v" #if($isFlow) v-if="isAuthority" #end>
  4. <view class="u-flex top-btn" :class="slide2" v-show="ids.length">
  5. <view class="button-left" @click.stop="cancel">
  6. <p class="u-m-t-10 u-font-28">{{$t('common.cancelText')}}</p>
  7. </view>
  8. <view class="button-center">
  9. <p class="u-m-t-10 u-font-28">{{$t('component.jnpf.common.selected')}}({{ids.length}})</p>
  10. </view>
  11. <view class="button-right u-m-t-12" @click.stop="checkAll">
  12. <p class="icon-ym icon-ym-app-checkAll " :style="{'color':this.checkedAll ? '#0293fc' : '#303133'}">
  13. </p>
  14. </view>
  15. </view>
  16. <view class="head-warp com-dropdown">
  17. <u-dropdown class="u-dropdown" ref="uDropdown" type="page" @open="showTop = true" @close="showTop = false">
  18. <u-dropdown-item :title="$t('app.apply.sort','排序')" :options="sortOptions">
  19. <view class="screen-box">
  20. <view class="screen-list" v-if="sortOptions.length">
  21. <view class="u-p-l-20 u-p-r-20 list">
  22. <scroll-view scroll-y="true" style="height: 100%;">
  23. <u-cell-group :border="false">
  24. <u-cell-item @click="cellClick(item)" :arrow="false" :title="item.labelI18nCode ? $t(item.labelI18nCode) + ' ' + $t(item.sortType) : item.label"
  25. v-for="(item, index) in sortOptions" :key="index" :title-style="{
  26. color: sortValue.includes(item.value) ? '#2979ff' : '#606266' }">
  27. <u-icon v-if="sortValue.includes(item.value)" name="checkbox-mark"
  28. color="#2979ff" size="32" />
  29. </u-cell-item>
  30. </u-cell-group>
  31. </scroll-view>
  32. </view>
  33. <view class="u-flex screen-btn">
  34. <text class="btn btn1" @click="handleSortReset">{{$t('common.cleanText','清空')}}</text>
  35. <text class="btn btn2" @click="handleSortSearch">{{$t('common.okText','确定')}}</text>
  36. </view>
  37. </view>
  38. <JnpfEmpty v-else></JnpfEmpty>
  39. </view>
  40. </u-dropdown-item>
  41. <u-dropdown-item :title="$t('app.apply.screen','筛选')">
  42. #if(${context.searchAll})
  43. <view class="screen-box u-flex-col">
  44. <view class="screen-list">
  45. <view class="u-p-l-20 u-p-r-20 list">
  46. <scroll-view scroll-y="true" :show-scrollbar="true" :enhanced="true" style="height: 100%;">
  47. <u-form :label-width="150" class="u-p-1-20 u-p-r-20">
  48. #if(${context.isKeyword})
  49. <u-form-item :label="$t('common.keyword','关键词')">
  50. <JnpfInput v-model="searchForm.jnpfKeyword" :placeholder="$t('common.enterKeyword','请输入关键词')" input-align='right' />
  51. </u-form-item>
  52. #end
  53. #AppSearchRendering()
  54. #if(${isFlow})
  55. <u-form-item label="状态">
  56. <JnpfSelect v-model="searchForm.jnpfFlowState" placeholder="请选择状态" :options="useDefine.flowStatusList" filterable/>
  57. </u-form-item>
  58. #end
  59. </u-form>
  60. </scroll-view>
  61. </view>
  62. <view class="u-flex screen-btn">
  63. <text @click="reset" class="btn btn1">{{$t('common.resetText')}}</text>
  64. <text @click="closeDropdown" class="btn btn2">{{$t('common.searchText')}}</text>
  65. </view>
  66. </view>
  67. </view>
  68. #else
  69. <JnpfEmpty></JnpfEmpty>
  70. #end
  71. </u-dropdown-item>
  72. </u-dropdown>
  73. </view>
  74. #if($isTab)
  75. <u-tabs :list="tabList" :current="tabKey" font-size="28" @change="onTabChange" height="80" name="fullName"/>
  76. #end
  77. <view class="list-warp">
  78. <mescroll-uni ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :up="upOption" :fixed="false">
  79. <view class="list u-p-b-20 u-p-l-20 u-p-r-20">
  80. <view class="list-box">
  81. <SwipeItem :list="list" :buttons="options" @action="actionClick" ref="swipeItem" :marginB="20" class="u-m-t-20">
  82. <template v-slot="{ item }">
  83. <view class="item" @click="goDetail(item)" style="border: 1px solid #fff;">
  84. <u-checkbox v-if="isBatchRemove" @change="checkboxChange($event,item)"
  85. v-model="item.checked" class="checkbox" @tap.stop shape="circle"/>
  86. <view class="u-line-1 item-cell" v-for="(column,i) in columnList" :key="i">
  87. <template v-if="column.jnpfKey != 'table'">
  88. <text class="item-cell-label">{{column.label}}:</text>
  89. <text class="item-cell-content" v-if="['calculate','inputNumber'].includes(column.jnpfKey) && column.thousands">{{toThousands(item[column.prop],column)}}</text>
  90. <text class="item-cell-content text-primary" v-else-if="column.jnpfKey == 'relationForm'" @click.stop="relationFormClick(item,column)" >{{item[column.prop]}}</text>
  91. <view class="item-cell-content" v-else-if="column.jnpfKey == 'sign'">
  92. <JnpfSign v-model="item[column.prop]" align="left" detailed />
  93. </view>
  94. <view class="item-cell-content" v-else-if="column.jnpfKey == 'signature'">
  95. <JnpfSignature v-model="item[column.prop]" align="left" detailed />
  96. </view>
  97. <view class="item-cell-content" v-else-if="column.jnpfKey == 'uploadImg'" @click.stop>
  98. <JnpfUploadImg v-model="item[column.prop]" detailed simple v-if="item[column.prop]&&item[column.prop].length" />
  99. </view>
  100. <view class="item-cell-content" v-else-if="column.jnpfKey == 'uploadFile'" @click.stop>
  101. <JnpfUploadFile v-model="item[column.prop]" detailed v-if="item[column.prop]&&item[column.prop].length" align="left" />
  102. </view>
  103. <view class="item-cell-content" v-else-if="column.jnpfKey == 'rate'">
  104. <JnpfRate v-model="item[column.prop]" :max="column.count" :allowHalf="column.allowHalf" disabled />
  105. </view>
  106. <view class="item-cell-content item-cell-slider" v-else-if="column.jnpfKey == 'slider'">
  107. <JnpfSlider v-model="item[column.prop]" :min="column.min" :max="column.max" :step="column.step" disabled />
  108. </view>
  109. <view class="item-cell-content" v-else-if="column.jnpfKey == 'input'">
  110. <JnpfInput v-model="item[column.prop]" detailed showOverflow :useMask="column.useMask" :maskConfig="column.maskConfig" align='left' />
  111. </view>
  112. <text class="item-cell-content" v-else>{{item[column.prop]}}</text>
  113. </template>
  114. <tableCell v-else @click.stop :label="column.label" :childList="item[column.prop]" @cRelationForm="relationFormClick" :children="column.children"
  115. ref="tableCell" :pageLen="3"/>
  116. </view>
  117. #if($isFlow)
  118. <view class="item-cell">
  119. <text class="item-cell-label">审批状态:</text>
  120. <text :style="{color:useDefine.getFlowStatusColor(item.flowState)}">
  121. {{useDefine.getFlowStatusContent(item.flowState)}}
  122. </text>
  123. </view>
  124. #end
  125. </view>
  126. </template>
  127. </SwipeItem>
  128. </view>
  129. </view>
  130. </mescroll-uni>
  131. </view>
  132. #if(${context.webType}=='2')
  133. <view v-if="!showTop">
  134. #foreach($btns in ${context.columnBtnsList})
  135. #if(${btns.value}=='add')
  136. <view class="com-addBtn" @click="addPage()" #if(${useBtnPermission}==true) v-if="${setPermission}.hasBtnP('btn_add',${menuId})" #end>
  137. <u-icon name="plus" size="60" color="#fff" />
  138. </view>
  139. #end
  140. #end
  141. </view>
  142. #end
  143. <view class="u-flex bottom-btn" :class="slide" v-show="isBatchRemove && list.length">
  144. <view class="button-preIcon" @click.stop="batchDelete">
  145. <p class="icon-ym icon-ym-app-delete u-m-b-8"></p>
  146. <p class="u-m-t-10 u-font-24">{{$t('common.delText','删除')}}</p>
  147. </view>
  148. </view>
  149. </view>
  150. </template>
  151. <script>
  152. import resources from '@/libs/resources.js'
  153. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  154. import tableCell from '../dynamicModel/components/tableCell.vue'
  155. import {
  156. getDictionaryDataSelector,
  157. getDataInterfaceRes
  158. } from '@/api/common'
  159. import {
  160. useBaseStore
  161. } from '@/store/modules/base'
  162. const baseStore = useBaseStore()
  163. import request from '@/utils/request'
  164. import appColumnList from './columnList'
  165. #if($isFlow)
  166. import {
  167. useDefineSetting
  168. } from '@/utils/useDefineSetting'
  169. import {
  170. getFlowStartFormId
  171. } from "@/api/workFlow/flowEngine";
  172. #end
  173. import jnpf from "@/utils/jnpf";
  174. import SwipeItem from "@/components/SwipeItem/index"
  175. const now = new Date()
  176. export default {
  177. mixins: [MescrollMixin],
  178. components: {
  179. tableCell,
  180. SwipeItem
  181. },
  182. data() {
  183. return {
  184. slide: '',
  185. slide2: '',
  186. checkedAll: false,
  187. ids: [],
  188. isBatchRemove: false,
  189. isAuthority:true,
  190. #if($isFlow)
  191. flowId : '',//请在此处填写流程id
  192. useDefine: useDefineSetting(),
  193. #end
  194. icon: resources.message.nodata,
  195. sortValue: [],
  196. searchForm: {
  197. #if(${context.isKeyword})
  198. jnpfKeyword:'',
  199. #end
  200. #foreach($searchAll in ${context.searchAll})
  201. #set($html = ${searchAll.html})
  202. #set($model = "${html.vModel}")
  203. #set($config = $html.config)
  204. #set($value = $html.value)
  205. #set($sourceType = $html.sourceType)
  206. #if($config.isFromParam) #set($isFromParam =$config.isFromParam) #else #set($isFromParam = false) #end
  207. #if($html.searchMultiple) #set($searchMultiple =$html.searchMultiple) #else #set($searchMultiple = false) #end
  208. #set($defaultValue="undefined")
  209. #if(${value})
  210. #if(${searchSystemParam.contains(${searchAll.html.config.jnpfKey})} && $sourceType == 4)
  211. #set($defaultValue="jnpf.getSearchRealValue('$value','$!html.format',now, $isFromParam, $searchMultiple)")
  212. #elseif($!config.valueType=='String')
  213. #set($defaultValue="'"+"${value}"+"'")
  214. #else
  215. #set($defaultValue=${value})
  216. #end
  217. #end
  218. ${model}:$defaultValue,
  219. #end
  220. },
  221. downOption: {
  222. use: true,
  223. auto: false
  224. },
  225. dataOptions:{
  226. },
  227. upOption: {
  228. page: {
  229. num: 0,
  230. size: ${context.pageSize},
  231. time: null,
  232. },
  233. empty: {
  234. use: true,
  235. icon: resources.message.nodata,
  236. tip: "暂无数据",
  237. fixed: true,
  238. zIndex: 5,
  239. },
  240. textNoMore: '没有更多数据',
  241. toTop: {
  242. bottom: 250
  243. }
  244. },
  245. #foreach($searchAll in ${context.searchAll})
  246. #set($html = ${searchAll.html})
  247. #list($html,'')
  248. #end
  249. list: [],
  250. appColumnList:appColumnList,
  251. listQuery: {
  252. moduleId:'${context.moduleId}',
  253. sidx: '',
  254. keyword: '',
  255. json: ''
  256. },
  257. options: [
  258. #if(${context.webType}=='2')
  259. #foreach($btns in ${context.columnBtnsList})
  260. #set($remove = "删除")
  261. #if(${btns.value}=='remove')
  262. #set($remove = "${btns.label}")
  263. {
  264. value: 'remove',
  265. text: '${remove}',
  266. text2: #if(${btns.labelI18nCode})'${btns.labelI18nCode}' #else '' #end,
  267. style: {
  268. backgroundColor: '#dd524d'
  269. }
  270. }
  271. #end
  272. #end
  273. #end
  274. ],
  275. sortOptions:[
  276. #foreach($html in ${context.sortList})
  277. {
  278. label: '${html.label}降序',
  279. labelI18nCode: '${html.labelI18nCode}',
  280. sortType: 'app.apply.descendingOrder',
  281. sidx: '${html.prop}',
  282. value: '-${html.prop}',
  283. sort: 'desc'
  284. },
  285. {
  286. label: '${html.label}升序',
  287. labelI18nCode: '${html.labelI18nCode}',
  288. sortType: 'app.apply.ascendingOrder',
  289. sidx: '${html.prop}',
  290. value: '${html.prop}',
  291. sort: 'asc'
  292. },
  293. #end
  294. ],
  295. ableAll:{
  296. #foreach($searchAll in ${context.searchAll})
  297. #set($html = ${searchAll.html})
  298. #set($childList = '')
  299. #appableAll($html $childList)
  300. #end
  301. },
  302. interfaceRes:{
  303. #foreach($searchAll in ${context.searchAll})
  304. #set($html = ${searchAll.html})
  305. #faceRes($html,'')
  306. #end
  307. },
  308. menuId:'',
  309. columnList:[],
  310. key:new Date(),
  311. dataValue:{},
  312. userInfo:{},
  313. firstInitSearchData:false,
  314. tabList: [],
  315. tabKey:0,
  316. showTop: false,
  317. }
  318. },
  319. onLoad(e){
  320. this.userInfo = uni.getStorageSync('userInfo') || {}
  321. this.menuId = e.menuId
  322. this.setDefaultQuery()
  323. this.dataAll()
  324. #if($isTab)
  325. this.getTabList()
  326. #end
  327. this.getColumnList()
  328. #if($isFlow)
  329. this.getFlowId()
  330. #end
  331. #if(${context.webType}=='2')
  332. #foreach($btns in ${context.columnBtnsList})
  333. #if(${btns.value}=='batchRemove')
  334. #if(${useBtnPermission}==true)
  335. if(${setPermission}.hasBtnP('btn_batchRemove',e.menuId)){
  336. this.isBatchRemove = true
  337. }
  338. #else
  339. this.isBatchRemove = true
  340. #end
  341. #end
  342. #end
  343. #end
  344. },
  345. onShow() {
  346. this.$nextTick(()=>{
  347. this.mescroll.resetUpScroll()
  348. })
  349. },
  350. onUnload() {
  351. uni.$off('refresh')
  352. },
  353. methods:{
  354. #if($isTab)
  355. async getTabList() {
  356. this.tabList = []
  357. #if(${context.hasAllTab})
  358. this.tabList.push({ fullName: '全部', id: '' });
  359. #end
  360. #foreach($searchAll in ${context.tabSearch})
  361. #set($html = ${searchAll.html})
  362. #set($config =$html.config)
  363. #set($model = "${html.vModel}")
  364. #if(${config.dataType} == 'dictionary')
  365. const data = await baseStore.getDicDataSelector('${config.dictionaryType}')
  366. const options = #if($html.props.value == 'enCode') data.map(o => ({ ...o, id: o.enCode }))#else data #end;
  367. this.tabList = [...this.tabList,...options]
  368. #else
  369. this.tabList = this.tabList.concat( #if(${html.options}) ${html.options} #else [] #end)
  370. #end
  371. this.tabKey = 0;
  372. this.listQuery = {...this.listQuery, ${model} : this.tabList.length? this.tabList[0].id:'' };
  373. #end
  374. },
  375. onTabChange(index){
  376. this.tabKey = index;
  377. let val = this.tabList[index].id
  378. #foreach($searchAll in ${context.tabSearch})
  379. #set($html = ${searchAll.html})
  380. #set($model = "${html.vModel}")
  381. this.listQuery.${model}=val
  382. #end
  383. this.mescroll.resetUpScroll();
  384. },
  385. #end
  386. toThousands(val, column) {
  387. if (val) {
  388. let valList = val.toString().split('.')
  389. let num = Number(valList[0])
  390. let newVal = column.thousands ? num.toLocaleString() : num
  391. return valList[1] ? newVal + '.' + valList[1] : newVal
  392. } else {
  393. return val
  394. }
  395. },
  396. dataAll(){
  397. #foreach($searchAll in ${context.searchAll})
  398. #set($html = ${searchAll.html})
  399. #options($html '')
  400. #end
  401. },
  402. #foreach($searchAll in ${context.searchAll})
  403. #set($html = ${searchAll.html})
  404. #codeOptionsList($html,'')
  405. #end
  406. setDefaultQuery() {
  407. const defaultSortConfig=#if(${context.defaultSortConfig}) ${context.defaultSortConfig} #else []#end
  408. const sortField = defaultSortConfig.map(o => (o.sort === 'desc' ? '-' : '') + o.field)
  409. this.listQuery.sidx = sortField.join(',')
  410. },
  411. //初始化查询的默认数据
  412. async initSearchData() {
  413. #set($formModel='this.searchForm')
  414. #foreach($html in ${context.mastsearchList})
  415. #set($fieLdsModel=$html)
  416. #indexDefaultData('mast',$fieLdsModel,${formModel})
  417. #end
  418. #foreach($html in ${context.searchList})
  419. #set($fieLdsModel=$html)
  420. #indexDefaultData('mastTable',$fieLdsModel,${formModel})
  421. #end
  422. #foreach($html in ${context.childSearch})
  423. #set($fieLdsModel=$html)
  424. #indexDefaultData('table',$fieLdsModel,${formModel})
  425. #end
  426. this.dataValue = JSON.parse(JSON.stringify(this.searchForm))
  427. },
  428. relationFormClick(item,column) {
  429. let vModel = column.__vModel__ +"_id"
  430. let id = item[vModel]
  431. let modelId = column.modelId
  432. if (!id || !modelId) return
  433. let config = {
  434. modelId: modelId,
  435. id: id,
  436. formTitle: '详情',
  437. noShowBtn: 1,
  438. noDataLog: 1,
  439. }
  440. this.$nextTick(() => {
  441. const url ='/pages/apply/dynamicModel/detail?config=' + this.jnpf.base64.encode(JSON.stringify(config),"UTF-8")
  442. uni.navigateTo({
  443. url: url
  444. })
  445. })
  446. },
  447. async upCallback(page) {
  448. this.cancel()
  449. if(!this.firstInitSearchData) {
  450. await this.initSearchData()
  451. this.firstInitSearchData = true
  452. }
  453. const query = {
  454. currentPage: page.num,
  455. pageSize: page.size,
  456. menuId : this.menuId,
  457. ...this.listQuery,
  458. ...this.searchForm,
  459. #if($isFlow)
  460. flowId:this.flowId,
  461. #end
  462. #set($queryDataType="0")
  463. #if(${context.page}=='1')
  464. #set($queryDataType="1")
  465. #end
  466. dataType:${queryDataType},
  467. }
  468. request({
  469. url: '/api/${context.module}/${context.className}/getList',
  470. method: 'post',
  471. data: query,
  472. }).then(res => {
  473. let _list = res.data.list;
  474. #set($list = "this.mescroll.endSuccess(_list.length);")
  475. #if(${context.page}=='1')
  476. #set($list = "this.mescroll.endSuccess(_list.length, false);")
  477. #end
  478. ${list}
  479. if (page.num == 1) this.list = [];
  480. const list = _list.map(o => ({
  481. show: false,
  482. ...o
  483. }));
  484. this.list = this.list.concat(_list);
  485. }).catch(() => {
  486. this.mescroll.endSuccess(this.list.length);
  487. })
  488. },
  489. open(index) {
  490. this.list[index].show = true;
  491. this.list.map((val, idx) => {
  492. if (index != idx) this.list[idx].show = false;
  493. })
  494. },
  495. actionClick(item) {
  496. if (this.options[item.index].value === 'remove') return this.handleClick(item.index)
  497. },
  498. handleClick(index) {
  499. #if(${context.webType}=='2')
  500. #if(${useBtnPermission}==true)
  501. if (!this.${setPermission}.hasBtnP("btn_remove",this.${menuId})) return this.$u.toast("未开启删除权限")
  502. #end
  503. const item = this.list[index]
  504. #if($isFlow)
  505. if(![0, 9].includes(item.flowState)){
  506. this.$u.toast("流程正在审核,请勿删除")
  507. this.list[index].show = false
  508. return
  509. }
  510. #end
  511. const _data={ids:[item.id] }
  512. request({
  513. url: '/api/${context.module}/${context.className}/batchRemove',
  514. data: _data,
  515. method: 'delete'
  516. }).then(res => {
  517. uni.showToast({
  518. title: res.msg,
  519. complete: () => {
  520. ${toast}
  521. this.mescroll.resetUpScroll()
  522. }
  523. })
  524. })
  525. #end
  526. },
  527. open(index) {
  528. this.list[index].show = true;
  529. this.list.map((val, idx) => {
  530. if (index != idx) this.list[idx].show = false;
  531. })
  532. },
  533. search() {
  534. if (this.isPreview == '1') return
  535. this.searchTimer && clearTimeout(this.searchTimer)
  536. this.searchTimer = setTimeout(() => {
  537. this.list = [];
  538. this.mescroll.resetUpScroll();
  539. }, 300)
  540. },
  541. #if($isFlow)
  542. getFlowId(){
  543. if (!this.flowId){
  544. this.isAuthority = false
  545. return this.$u.toast("流程模板的flowId未填写")
  546. }
  547. getFlowStartFormId(this.flowId).then(res=>{
  548. this.isAuthority = true
  549. }).catch(()=>{
  550. this.isAuthority = false
  551. })
  552. },
  553. goDetail(item) {
  554. let flowState =item.flowState
  555. let id = item.id
  556. let btnType = ''
  557. let btnList = []
  558. #foreach($btns in ${context.columnBtnsList})
  559. #if(${btns.value}=='edit')
  560. btnList.push('btn_edit')
  561. #end
  562. #if(${btns.value}=='detail')
  563. btnList.push('btn_detail')
  564. #end
  565. #end
  566. if(btnList.includes('btn_detail')){
  567. btnType = "btn_detail"
  568. }
  569. if(btnList.includes('btn_edit')){
  570. btnType = "btn_edit"
  571. }
  572. if(!btnType) return
  573. #set($edit="")
  574. #set($detail="")
  575. #if(${useBtnPermission}==true)
  576. #foreach($btns in ${context.columnBtnsList})
  577. #if(${btns.value}=='edit')
  578. #set($edit="btn_edit")
  579. #end
  580. #if(${btns.value}=='detail')
  581. #set($detail="btn_detail")
  582. #end
  583. #end
  584. if(!this.${setPermission}.hasBtnP('${edit}',this.${menuId}) && !this.${setPermission}.hasBtnP('${detail}',this.${menuId})) return
  585. if(this.${setPermission}.hasBtnP('${detail}',this.${menuId})) btnType = 'btn_detail'
  586. if(this.${setPermission}.hasBtnP('${edit}',this.${menuId})) btnType = 'btn_edit'
  587. #end
  588. this.jumPage(id, flowState,btnType)
  589. },
  590. addPage() {
  591. this.jumPage()
  592. },
  593. jumPage(id, status,btnType){
  594. if (!id && !status) btnType = 'btn_add'
  595. let opType = '-1'
  596. if (![0, 8, 9].includes(status) && btnType != 'btn_add') opType = 0
  597. const config = {
  598. id: id || '',
  599. flowId: this.flowId,
  600. opType,
  601. status: status || '',
  602. jurisdictionType: btnType || ''
  603. }
  604. uni.navigateTo({
  605. url: '/pages/workFlow/flowBefore/index?config=' + this.jnpf.base64.encode(JSON.stringify(config), "UTF-8")
  606. })
  607. },
  608. #else
  609. goDetail(item) {
  610. #if(${context.webType}=='2')
  611. let id = item.id
  612. let btnType = ''
  613. let btnList = []
  614. #foreach($btns in ${context.columnBtnsList})
  615. #if(${btns.value}=='edit')
  616. btnList.push('btn_edit')
  617. #end
  618. #if(${btns.value}=='detail')
  619. btnList.push('btn_detail')
  620. #end
  621. #end
  622. #set($edit="")
  623. #set($detail="")
  624. #if(${useBtnPermission}==true)
  625. #foreach($btns in ${context.columnBtnsList})
  626. #if(${btns.value}=='edit')
  627. #set($edit="btn_edit")
  628. #end
  629. #if(${btns.value}=='detail')
  630. #set($detail="btn_detail")
  631. #end
  632. #end
  633. if(!this.${setPermission}.hasBtnP('${detail}',this.${menuId})){
  634. btnList = btnList.filter(o=>{return o !== '${detail}'})
  635. }
  636. if(!this.${setPermission}.hasBtnP('${edit}',this.${menuId})){
  637. btnList = btnList.filter(o=>{return o !== '${edit}'})
  638. }
  639. #end
  640. if(btnList.length==0) return
  641. this.jumPage(id,btnList)
  642. #end
  643. },
  644. addPage() {
  645. this.jumPage()
  646. },
  647. jumPage(id, btnList) {
  648. #if(${context.webType}=='2')
  649. let idVal = id ? "&id=" + id : ''
  650. let idList = []
  651. for(let i=0;i<this.list.length;i++){
  652. idList.push(this.list[i].id)
  653. }
  654. let idListVal = "&idList="+idList
  655. if (!id){
  656. uni.navigateTo({
  657. url: "./form?menuId=" + this.menuId + "&jurisdictionType=btn_add"
  658. })
  659. } else if(btnList.includes('btn_detail')){
  660. uni.navigateTo({
  661. url: "./detail?menuId=" + this.menuId + "&btnList=" + btnList + idVal+idListVal
  662. })
  663. } else if(btnList.includes('btn_edit')){
  664. uni.navigateTo({
  665. url: "./form?menuId=" + this.menuId + "&jurisdictionType=btn_edit&btnList=" + btnList + idVal+idListVal
  666. })
  667. }
  668. #end
  669. },
  670. #end
  671. checkboxChange(e, item) {
  672. if (e.value) {
  673. this.ids.push(item.id)
  674. } else {
  675. this.ids = this.ids.filter(o => o !== item.id)
  676. }
  677. if (this.ids.length){
  678. this.isBatchRemove = true
  679. }
  680. },
  681. batchDelete() {
  682. const item = this.ids
  683. if (!item.length) {
  684. return this.$u.toast("请选择一条数据")
  685. }
  686. const _data={ ids:item }
  687. uni.showModal({
  688. title: '提示',
  689. content: '删除后数据无法恢复',
  690. success: (res) => {
  691. if (res.confirm) {
  692. request({
  693. url: '/api/${context.module}/${context.className}/batchRemove',
  694. data: _data,
  695. method: 'delete'
  696. }).then(res => {
  697. uni.showToast({
  698. title: res.msg,
  699. complete: () => {
  700. this.cancel()
  701. ${toast}
  702. this.mescroll.resetUpScroll()
  703. }
  704. })
  705. })
  706. }
  707. }
  708. })
  709. },
  710. openBatchOperate() {
  711. this.isBatchRemove = !this.isBatchRemove
  712. if (this.isBatchRemove) {
  713. this.slide = 'slide-up'
  714. this.slide2 = 'slide-up2'
  715. }
  716. },
  717. checkAll() {
  718. this.checkedAll = !this.checkedAll
  719. this.isBatchRemove = true
  720. this.ids = []
  721. this.list = this.list.map(o => ({
  722. ...o,
  723. checked: this.checkedAll,
  724. }))
  725. this.list.forEach(o=>{
  726. if(this.checkedAll) this.ids.push(o.id)
  727. })
  728. },
  729. cancel() {
  730. this.list = this.list.map(o => ({
  731. ...o,
  732. checked: false
  733. }))
  734. this.checkedAll = false
  735. this.ids = []
  736. },
  737. getColumnList() {
  738. let columnPermissionList = []
  739. let _appColumnList =this.appColumnList
  740. #if(${context.useColumnPermission}==true)
  741. let permissionList = uni.getStorageSync('permissionList')
  742. let list = permissionList.filter(o => o.modelId === this.menuId)
  743. let _columnList = list[0] && list[0].column ? list[0].column : []
  744. for (let i = 0; i < _appColumnList.length; i++) {
  745. let _app = _appColumnList[i].prop
  746. inner: for (let j = 0; j < _columnList.length; j++) {
  747. let _encode = _columnList[j].enCode
  748. if(_app == _encode){
  749. columnPermissionList.push(this.appColumnList[i])
  750. break inner
  751. }
  752. }
  753. }
  754. #else
  755. for (let i = 0; i < _appColumnList.length; i++) {
  756. columnPermissionList.push(_appColumnList[i])
  757. }
  758. #end
  759. this.columnList = this.transformColumnList(columnPermissionList, this.dataOptions)
  760. },
  761. transformColumnList(columnList, dataOptions) {
  762. let list = []
  763. for (let i = 0; i < columnList.length; i++) {
  764. let e = columnList[i]
  765. if(e.jnpfKey != 'calculate'){
  766. let columProp = e.prop
  767. let label = e.label
  768. let option = null
  769. let options = columProp + "Options"
  770. if (!columProp.includes('-')) {
  771. columProp = columProp
  772. e.label = e.labelI18nCode ? this.$t(e.labelI18nCode):label
  773. e.prop = columProp
  774. e.option = option
  775. list.push(e)
  776. } else {
  777. e.vModel = columProp.split('-')[1]
  778. e.childLabel = e.fullNameI18nCode && e.fullNameI18nCode[1] ? this.$t(e.fullNameI18nCode[1]): e.label.split('-')[1]
  779. options = e.vModel + "Options"
  780. let prop = columProp.split('-')[0]
  781. let label = e.fullNameI18nCode && e.fullNameI18nCode[0] ? this.$t(e.fullNameI18nCode[0]): e.label.split('-')[0]
  782. let newItem = {
  783. align: "center",
  784. jnpfKey: "table",
  785. prop,
  786. label,
  787. children: []
  788. }
  789. if (!list.some(o => o.prop === prop)) list.push(newItem)
  790. for (let i = 0; i < list.length; i++) {
  791. if (list[i].prop === prop) {
  792. e.prop = e.prop
  793. e.vModel = e.vModel
  794. e.option = option
  795. list[i].children.push(e)
  796. break
  797. }
  798. }
  799. }
  800. }
  801. }
  802. return list
  803. },
  804. cellClick(item) {
  805. const findIndex = this.sortValue.findIndex(o => o === item.value);
  806. if (findIndex < 0) {
  807. const findLikeIndex = this.sortValue.findIndex(o => o.indexOf(item.sidx) > -1);
  808. if (findLikeIndex > -1) this.sortValue.splice(findLikeIndex, 1)
  809. this.sortValue.push(item.value)
  810. } else {
  811. this.sortValue.splice(findIndex, 1)
  812. }
  813. },
  814. handleSortReset() {
  815. this.sortValue = []
  816. },
  817. handleSortSearch() {
  818. if (this.sortValue.length) {
  819. this.listQuery.sidx = this.sortValue.join(',')
  820. } else {
  821. this.setDefaultQuery()
  822. }
  823. this.$refs.uDropdown.close();
  824. this.$nextTick(() => {
  825. this.list = [];
  826. this.mescroll.resetUpScroll();
  827. })
  828. },
  829. reset() {
  830. this.searchForm = JSON.parse(JSON.stringify(this.dataValue))
  831. this.key = new Date()
  832. },
  833. closeDropdown() {
  834. this.$refs.uDropdown.close();
  835. this.$nextTick(() => {
  836. this.list = [];
  837. this.mescroll.resetUpScroll();
  838. })
  839. },
  840. dataList(data){
  841. let _list =data.list
  842. return _list;
  843. },
  844. },
  845. }
  846. </script>
  847. <style lang="scss">
  848. page {
  849. background-color: #f0f2f6;
  850. height: 100%;
  851. /* #ifdef MP-ALIPAY */
  852. position: absolute;
  853. top: 0;
  854. left: 0;
  855. width: 100%;
  856. /* #endif */
  857. }
  858. :deep(.u-cell) {
  859. padding: 0rpx;
  860. height: 112rpx;
  861. }
  862. </style>