|
|
@@ -0,0 +1,100 @@
|
|
|
+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) {
|
|
|
+ console.log(i)
|
|
|
+ paramList.push({
|
|
|
+ field:i,
|
|
|
+ value:str[i],
|
|
|
+ condition:'like'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ params['paramList'] =paramList
|
|
|
+ console.log(params)
|
|
|
+ // 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){
|
|
|
+ console.log(that._props.widget.options)
|
|
|
+ var options = that._props.widget.options
|
|
|
+ console.log(buttonName, rowIndex, row, that)
|
|
|
+ if(buttonName == 'delete'){
|
|
|
+ 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 == 'edit'){
|
|
|
+ that.getFormRef().showDialog('edit',row)
|
|
|
+ }else if(buttonName == 'detail'){
|
|
|
+ that.getFormRef().showDialog('detail',row)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 表单初始值
|
|
|
+ OnDialogOpened: function(that){
|
|
|
+ // console.log(that)
|
|
|
+ // that.getFormRef().getFormData()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 工具
|
|
|
+ * @returns {{ConvertPinyin: (function(*=): string)}}
|
|
|
+ */
|
|
|
+export function commonTable() {
|
|
|
+ return Table
|
|
|
+}
|