| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- import request from './request'
- import loadPinYinInit from '../../lib/ChineseHelper'
- import {
- formMethod
- } from './form-common'
- let Table = {
- ObtainTableTitle: function(data) {
- var tableName = data._props.widget.options.databaseName
- // console.log(data)
- // console.log(data._props.widget.options)
- var param = {
- tableName: tableName
- }
- //初始化表格数据
- formMethod().other('', 'admin-table/initializeHeader', param).then(res => {
- console.log(res)
- data.setTableColumn(res.data)
- })
- },
- // 通过配置获取表格数据
- ObtainTable: function(data) {
- //初始化表格数据
- var tableData = data._props.widget.options
- let params = {
- "limit": data.getWidgetRef(tableData.name).pageSize,
- "page": data.getWidgetRef(tableData.name).currentPage,
- }
- var str = data.getFormRef().getFormData(false)
- // 参数
- let paramList = []
- // 名称
- for (let i in str) {
- if (str[i] != '') {
- var code = ''
- var index = i.lastIndexOf("_")
- var field = index != -1 ? field = i.substring(index + 1, i.length) : field = i
- paramList.push({
- field,
- value: str[i],
- condition: data.getFormRef().getWidgetRef(i, false).field.options
- .screenOperator
- })
- }
- }
- params['paramList'] = paramList
- // let mingchen=this.getFormRef().getFieldValue('search_mingchen')
- // if(mingchen){
- // paramList.push({
- // field:'name',
- // value:mingchen,
- // condition:'like'
- // })
- // params['paramList'] =paramList
- // }
- formMethod().selectPage('', tableData.databaseName, params, tableData.databaseName + ':page')
- .then(res => {
- data.setTableData(res.data.records)
- data.setPagination({
- currentPage: parseInt(res.data.current),
- pageSize: parseInt(res.data.size),
- total: parseInt(res.data.total)
- })
- // return response
- })
- },
- ObtainTableButton: function(buttonName, rowIndex, row, that) {
- var options = that._props.widget.options
- console.log('=======》', buttonName, rowIndex, row, that)
- if (buttonName.indexOf('delete') != -1) {
- that.$confirm("是否删除,继续?", "提示", {
- confirmButtonText: "确定",
- cance1ButtonText: "取消",
- type: "warning"
- }).then(() => {
- formMethod().delete('', options.databaseName, row.id, options.databaseName + ':page')
- .then((res) => {
- if (res.code == 20000) {
- that.$message.success("删除成功") //----重新加载表数据
- that.handleOnCreated()
- }
- })
- // this,$message.success("删除成功")
- })
- } else if (buttonName.indexOf('edit') != -1) {
- // let form = that.getFormRef().getFormData(false)
- // let tableName = options.databaseName; //定义的表名
- // var paramList = []
- // for (let i in form) {
- // paramList.push({
- // condition: that.getFormRef().getWidgetRef(i, false)._props.field.options
- // .screenOperator,
- // field: i,
- // value: form[i]
- // })
- // }
- // var params = {
- // paramList
- // }
- // formMethod().select('', tableName, params, 'query:form')
- // .then(res => {
- // for (let i in form) {
- // that.getFormRef().setFieldValue(i, res.data[0][i])
- // }
- // })
- that.getFormRef().showDialog('edit', row, {
- operation: 'edit'
- })
- } else if (buttonName.indexOf('detail') != -1) {
- that.getFormRef().showDialog('detail', row)
- }
- },
- // 表单初始值
- OnDialogOpened: function(that) {
- // console.log(that)
- // that.getFormRef().getFormData()
- }
- }
- /**
- * 工具
- * @returns {{ConvertPinyin: (function(*=): string)}}
- */
- export function commonTable() {
- return Table
- }
|