You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

281 lines
11 KiB

3 years ago
  1. <template>
  2. <section class="page-container border padding">
  3. <el-row>
  4. <el-input v-model="filters.key" style="width: 20%;" placeholder="模糊查询"></el-input>
  5. <el-button v-loading="load.list" :disabled="load.list==true" @click="searchXmRptDatas" icon="el-icon-search">查询</el-button>
  6. <span style="float:right;">
  7. <el-button type="danger" v-loading="load.del" @click="batchDel" :disabled="this.sels.length===0 || load.del==true" icon="el-icon-delete" plain></el-button>
  8. </span>
  9. </el-row>
  10. <el-row class="padding-top">
  11. <!--列表 XmRptData xm_rpt_data-->
  12. <el-table ref="xmRptDataTable" :data="xmRptDatas" :height="maxTableHeight" @sort-change="sortChange" highlight-current-row v-loading="load.list" border @selection-change="selsChange" @row-click="rowClick" style="width: 100%;">
  13. <el-table-column type="selection" width="55" show-overflow-tooltip fixed="left"></el-table-column>
  14. <el-table-column prop="rptName" label="报告名称" min-width="120" show-overflow-tooltip>
  15. <template slot-scope="scope">
  16. <span> {{scope.row.rptName}} </span>
  17. </template>
  18. </el-table-column>
  19. <el-table-column prop="cuserid" label="创建人编号" min-width="120" show-overflow-tooltip>
  20. <template slot-scope="scope">
  21. <span> {{scope.row.cuserid}} </span>
  22. </template>
  23. </el-table-column>
  24. <el-table-column prop="cusername" label="创建人名称" min-width="120" show-overflow-tooltip>
  25. <template slot-scope="scope">
  26. <span> {{scope.row.cusername}} </span>
  27. </template>
  28. </el-table-column>
  29. <el-table-column prop="bizDate" label="业务日期" min-width="120" show-overflow-tooltip>
  30. <template slot-scope="scope">
  31. <span> {{scope.row.bizDate}} </span>
  32. </template>
  33. </el-table-column>
  34. <el-table-column label="操作" width="100" fixed="right">
  35. <template scope="scope">
  36. <el-button type="primary" @click="$emit('select',scope.row)" icon="el-icon-edit" plain>选择</el-button>
  37. </template>
  38. </el-table-column>
  39. </el-table>
  40. </el-row>
  41. <el-pagination layout="total, sizes, prev, pager, next" @current-change="handleCurrentChange" @size-change="handleSizeChange" :page-sizes="[10,20, 50, 100, 500]" :current-page="pageInfo.pageNum" :page-size="pageInfo.pageSize" :total="pageInfo.total" style="float:right;"></el-pagination>
  42. </section>
  43. </template>
  44. <script>
  45. import util from '@/common/js/util';//全局公共库
  46. import config from '@/common/config';//全局公共库
  47. import { initDicts,listXmRptData, delXmRptData, batchDelXmRptData,editSomeFieldsXmRptData } from '@/api/xm/core/xmRptData';
  48. import { mapGetters } from 'vuex'
  49. export default {
  50. name:'xmRptDataList',
  51. components: {
  52. },
  53. props:['visible','xmRptConfig'],
  54. computed: {
  55. ...mapGetters(['userInfo']),
  56. },
  57. watch:{
  58. visible(val){
  59. if(val==true){
  60. this.initData();
  61. this.searchXmRptDatas()
  62. }
  63. }
  64. },
  65. data() {
  66. return {
  67. filters: {
  68. key: ''
  69. },
  70. xmRptDatas: [],//查询结果
  71. pageInfo:{//分页数据
  72. total:0,//服务器端收到0时,会自动计算总记录数,如果上传>0的不自动计算。
  73. pageSize:10,//每页数据
  74. count:false,//是否需要重新计算总记录数
  75. pageNum:1,//当前页码、从1开始计算
  76. orderFields:[],//排序列 如 ['sex','student_id'],必须为数据库字段
  77. orderDirs:[]//升序 asc,降序desc 如 性别 升序、学生编号降序 ['asc','desc']
  78. },
  79. load:{ list: false, edit: false, del: false, add: false },//查询中...
  80. sels: [],//列表选中数据
  81. dicts:{
  82. //sex: [{id:'1',name:'男'},{id:'2',name:'女'}]
  83. },//下拉选择框的所有静态数据 params={categoryId:'all',itemCodes:['sex']} 返回结果 {sex: [{id:'1',name:'男'},{id:'2',name:'女'}]}
  84. addFormVisible: false,//新增xmRptData界面是否显示
  85. addForm: {
  86. cfgId:'',id:'',rptName:'',rptData:'',cuserid:'',cbranchId:'',cusername:'',ctime:'',bizDate:'',bizType:''
  87. },
  88. editFormVisible: false,//编辑界面是否显示
  89. editForm: {
  90. cfgId:'',id:'',rptName:'',rptData:'',cuserid:'',cbranchId:'',cusername:'',ctime:'',bizDate:'',bizType:''
  91. },
  92. maxTableHeight:300,
  93. }
  94. },//end data
  95. methods: {
  96. ...util,
  97. handleSizeChange(pageSize) {
  98. this.pageInfo.pageSize=pageSize;
  99. this.getXmRptDatas();
  100. },
  101. handleCurrentChange(pageNum) {
  102. this.pageInfo.pageNum = pageNum;
  103. this.getXmRptDatas();
  104. },
  105. // 表格排序 obj.order=ascending/descending,需转化为 asc/desc ; obj.prop=表格中的排序字段,字段驼峰命名
  106. sortChange( obj ){
  107. if(obj.order==null){
  108. this.pageInfo.orderFields=[];
  109. this.pageInfo.orderDirs=[];
  110. }else{
  111. var dir='asc';
  112. if(obj.order=='ascending'){
  113. dir='asc'
  114. }else{
  115. dir='desc';
  116. }
  117. this.pageInfo.orderFields=[util.toLine(obj.prop)];
  118. this.pageInfo.orderDirs=[dir];
  119. }
  120. this.getXmRptDatas();
  121. },
  122. searchXmRptDatas(){
  123. this.pageInfo.count=true;
  124. this.getXmRptDatas();
  125. },
  126. //获取列表 XmRptData xm_rpt_data
  127. getXmRptDatas() {
  128. let params = {
  129. pageSize: this.pageInfo.pageSize,
  130. pageNum: this.pageInfo.pageNum,
  131. total: this.pageInfo.total,
  132. count:this.pageInfo.count
  133. };
  134. if(this.pageInfo.orderFields!=null && this.pageInfo.orderFields.length>0){
  135. let orderBys=[];
  136. for(var i=0;i<this.pageInfo.orderFields.length;i++){
  137. orderBys.push(this.pageInfo.orderFields[i]+" "+this.pageInfo.orderDirs[i])
  138. }
  139. params.orderBy= orderBys.join(",")
  140. }
  141. if(this.filters.key){
  142. params.key=this.filters.key
  143. }
  144. if(!this.xmRptConfig || !this.xmRptConfig.id){
  145. return;
  146. }
  147. params.cfgId=this.xmRptConfig.id
  148. this.load.list = true;
  149. listXmRptData(params).then((res) => {
  150. var tips=res.data.tips;
  151. if(tips.isOk){
  152. this.pageInfo.total = res.data.total;
  153. this.pageInfo.count=false;
  154. this.xmRptDatas = res.data.data;
  155. }else{
  156. this.$notify({ position:'bottom-left',showClose:true, message: tips.msg, type: 'error' });
  157. }
  158. this.load.list = false;
  159. }).catch( err => this.load.list = false );
  160. },
  161. //显示编辑界面 XmRptData xm_rpt_data
  162. showEdit: function ( row,index ) {
  163. this.editFormVisible = true;
  164. this.editForm = Object.assign({}, row);
  165. },
  166. //显示新增界面 XmRptData xm_rpt_data
  167. showAdd: function () {
  168. this.addFormVisible = true;
  169. //this.addForm=Object.assign({}, this.editForm);
  170. },
  171. afterAddSubmit(){
  172. this.addFormVisible=false;
  173. this.pageInfo.count=true;
  174. this.getXmRptDatas();
  175. },
  176. afterEditSubmit(){
  177. this.editFormVisible=false;
  178. },
  179. //选择行xmRptData
  180. selsChange: function (sels) {
  181. this.sels = sels;
  182. },
  183. //删除xmRptData
  184. handleDel: function (row,index) {
  185. this.$confirm('确认删除该记录吗?', '提示', {
  186. type: 'warning'
  187. }).then(() => {
  188. this.load.del=true;
  189. let params = { id:row.id };
  190. delXmRptData(params).then((res) => {
  191. this.load.del=false;
  192. var tips=res.data.tips;
  193. if(tips.isOk){
  194. this.searchXmRptDatas();
  195. }
  196. this.$notify({ position:'bottom-left', showClose:true, message: tips.msg, type: tips.isOk?'success':'error' });
  197. }).catch( err => this.load.del=false );
  198. });
  199. },
  200. //批量删除xmRptData
  201. batchDel: function () {
  202. if(this.sels.length<=0){
  203. return;
  204. }
  205. var params=this.sels.map(i=>{
  206. return { id:i.id}
  207. })
  208. this.$confirm('确认删除选中记录吗?', '提示', {
  209. type: 'warning'
  210. }).then(() => {
  211. this.load.del=true;
  212. batchDelXmRptData(params).then((res) => {
  213. this.load.del=false;
  214. var tips=res.data.tips;
  215. if( tips.isOk ){
  216. this.searchXmRptDatas();
  217. }
  218. this.$notify({ position:'bottom-left',showClose:true, message: tips.msg, type: tips.isOk?'success':'error'});
  219. }).catch( err => this.load.del=false );
  220. });
  221. },
  222. editSomeFields(row,fieldName,$event){
  223. let params={};
  224. if(this.sels.length>0){
  225. if(!this.sels.some(k=> k.id==row.id)){
  226. this.$notify({position:'bottom-left',showClose:true,message:'请编辑选中的行',type:'warning'})
  227. Object.assign(this.editForm,this.editFormBak)
  228. return;
  229. }
  230. params['ids']=this.sels.map(i=>i.id)
  231. }else{
  232. params['ids']=[row].map(i=>i.id)
  233. }
  234. params[fieldName]=$event
  235. var func = editSomeFieldsXmRptData
  236. func(params).then(res=>{
  237. let tips = res.data.tips;
  238. if(tips.isOk){
  239. if(this.sels.length>0){
  240. this.searchXmRptDatas();
  241. }
  242. this.editFormBak=[...this.editForm]
  243. }else{
  244. Object.assign(this.editForm,this.editFormBak)
  245. this.$notify({position:'bottom-left',showClose:true,message:tips.msg,type:tips.isOk?'success':'error'})
  246. }
  247. }).catch((e)=>Object.assign(this.editForm,this.editFormBak))
  248. },
  249. rowClick: function(row, event, column){
  250. this.editForm=row
  251. this.editFormBak={...row};
  252. this.$emit('row-click',row, event, column);// @row-click="rowClick"
  253. },
  254. initData: function(){
  255. },
  256. },//end methods
  257. mounted() {
  258. this.$nextTick(() => {
  259. initDicts(this);
  260. this.initData()
  261. this.searchXmRptDatas();
  262. this.maxTableHeight = util.calcTableMaxHeight(this.$refs.xmRptDataTable.$el)
  263. });
  264. }
  265. }
  266. </script>
  267. <style scoped>
  268. </style>