Browse Source

附件上传

master
nizongfeng 1 year ago
parent
commit
d6eaf852fc
7 changed files with 341 additions and 15 deletions
  1. +25
    -1
      application/admin/controller/OrderMain.php
  2. +67
    -0
      application/admin/dao/FileDao.php
  3. +2
    -2
      application/admin/dao/ReceiptOrderDao.php
  4. +20
    -0
      application/admin/model/File.php
  5. +108
    -1
      application/admin/view/payment_order/index.html
  6. +111
    -3
      application/admin/view/receipt_order/index.html
  7. +8
    -8
      application/common/library/Upload.php

+ 25
- 1
application/admin/controller/OrderMain.php View File

@@ -2,6 +2,7 @@

namespace app\admin\controller;

use app\admin\dao\FileDao;
use app\admin\dao\GroupDao;
use app\admin\dao\OrderMainDao;
use app\admin\dao\OrderMemoDao;
@@ -20,7 +21,7 @@ use think\Loader;
*/
class OrderMain extends Backend
{
protected $noNeedRight = ['getOrderList',"save","delSubOrder","subOrderSave","getShowInfo","newAdd","insertOrderMain","addMemo","getMemoList","setHotFlag"];
protected $noNeedRight = ['getOrderList',"save","delSubOrder","subOrderSave","getShowInfo","newAdd","insertOrderMain","addMemo","getMemoList","setHotFlag","addFileInfo","getFileList"];
/**
* OrderMain模型对象
* @var \app\admin\model\OrderMain
@@ -168,4 +169,27 @@ class OrderMain extends Backend
$result = $model->setHotFlag($params["order_id"],$params["val"]);
return json($result);
}

/**
* 添加附件记录
* @return \think\response\Json
*/
public function addFileInfo(){
$params=$this->request->post();
$params['create_id']=$this->auth->id;
$model = new FileDao();
$result = $model->addInfo($params["type"],$params["file"],$params['name'],$params['id'],$params['create_id']);
return json($result);
}

/**
* 获取附件列表
* @return \think\response\Json
*/
public function getFileList(){
$params=$this->request->post();
$model = new FileDao();
$result = $model->getList($params["type"],$params['id']);
return json($result);
}
}

+ 67
- 0
application/admin/dao/FileDao.php View File

@@ -0,0 +1,67 @@
<?php
namespace app\admin\dao;
/**
* Created by PhpStorm.
* User: nizongfeng
* Date: 2023/2/7
* Time: 11:00
*/

use app\admin\command\Util;
use app\admin\model\File;
use think\Exception;

class FileDao
{
/**
* 添加详情
* @param $type
* @param $file
* @param $id
* @return array
*/
public function addInfo($type, $file, $name, $id, $create_id){
try{
$fileModel = new File();
$data = [
"type"=>$type,
"file"=>$file,
"name"=>$name,
"obj_id"=>$id,
"create_id"=>$create_id
];
if (!empty($create_id)) {
$adminDao = new AdminDao();
$admin = $adminDao->getInfoById($create_id);
if ($admin["flag"]) {
$data["create_name"] = $admin["data"]["nickname"];
}
}
$fileModel->insert($data);
return Util::returnArrSu("成功");
}catch (Exception $e){
return Util::returnArrEr("失败:".$e->getMessage());
}
}

/**
* 获取列表
* @param $type
* @param $file
* @param $id
* @return array
*/
public function getList($type, $id){
try{
$fileModel = new File();
$where = [
"type"=>$type,
"obj_id"=>$id
];
$list = $fileModel->where($where)->order("id","DESC")->select()->toArray();
return Util::returnArrSu("成功", $list);
}catch (Exception $e){
return Util::returnArrEr("失败:".$e->getMessage());
}
}
}

+ 2
- 2
application/admin/dao/ReceiptOrderDao.php View File

@@ -119,9 +119,9 @@ class ReceiptOrderDao

try {
$where = ["a.del_flag"=>0,"a.group_id"=>$param['group_id']];
if (empty($param['order_id'])) {
if (!empty($param['order_id'])) {
$orderMainModel = new OrderMain();
$orderMain = $orderMainModel->where(["id"=>$param['order_id']])->select()->find();
$orderMain = $orderMainModel->where(["id"=>$param['order_id']])->find();
if ($orderMain == null || empty($orderMain['receipt_order_id'])) {
$where["a.id"] = 0;
}else{


+ 20
- 0
application/admin/model/File.php View File

@@ -0,0 +1,20 @@
<?php
namespace app\admin\model;

use think\Model;
/**
* Created by PhpStorm.
* User: nizongfeng
* Date: 2023/2/7
* Time: 11:01
*/
class File extends Model
{
// 表名
protected $name = 'file';

// 追加属性
protected $append = [

];
}

+ 108
- 1
application/admin/view/payment_order/index.html View File

@@ -77,7 +77,7 @@
<el-button type="primary" size="mini" @click="edit(scope.row)" icon="el-icon-edit" style="margin: 5px;">编辑</el-button>
<el-button type="success" size="mini" @click="editOrderDivShow(scope.row)" icon="el-icon-share" style="margin: 5px;">订单</el-button>
<el-button type="danger" size="mini" v-if="scope.row.status==0" icon="el-icon-delete" @click="delAll(scope.row.id)" style="margin: 5px;">删除</el-button>
<el-button type="danger" size="mini" icon="el-icon-search" @click="" style="margin: 5px;">附件</el-button>
<el-button type="danger" size="mini" icon="el-icon-search" @click="showFile(scope.row.id)" style="margin: 5px;">附件</el-button>
</el-button-group>
</template>
</el-table-column>
@@ -294,6 +294,53 @@
</div>
</el-dialog>
</transition>

<transition name="bounce" v-if="showFileFlag">
<el-dialog title="附件详情" :visible.sync="showFileFlag" width="90%" top="15px">
<el-form ref="form" label-width="100px" style="width: 100%;padding-bottom: 20px">
<div style="display: flex;width: 100%">
<el-form-item label="账单ID:" style="width: 80%">
<div v-html="fileData.id"></div>
</el-form-item>
</div>
<div>
<el-form-item label="名称标识:" style="width: 80%">
<el-input v-model="fileData.name" style="width: 120px;" placeholder="请输入内容" clearable></el-input>
</el-form-item>
</div>
<div>
<el-form-item label="文件:" style="width: 80%">
<div>
<el-upload
:multiple="false"
:limit="1"
class="upload-demo"
action="/hotel.php/ajax/upload"
:on-change="handleChange"
:on-exceed="handleExceed"
:file-list="fileList">
<el-button size="small" type="primary">点击上传</el-button>
</el-upload>
</div>
</el-form-item>
</div>
<div>
<el-button type="primary" @click="fileSubmit()" >提交</el-button>
</div>
</el-form>
<el-table ref="multipleTable" :data="fileTable" border tooltip-effect="dark" style="font-size:12px;width: 100%;margin-top: 12px">
<el-table-column prop="name" label="名称标识" min-width="140" ></el-table-column>
<el-table-column prop="create_name" label="创建人" min-width="70" ></el-table-column>
<el-table-column prop="create_time" label="创建时间" min-width="70" ></el-table-column>
<el-table-column label="点击下载" min-width="40" >
<template slot-scope="scope">
<el-link :href="scope.row.file" target="_blank" style="color: #0a568c">下载</el-link>
</template>
</el-table-column>

</el-table>
</el-dialog>
</transition>
</div>
</body>
<!-- import Vue before Element -->
@@ -403,6 +450,15 @@
}
}]
},
showFileFlag:false,
fileData:{
"id":"",
"name":"",
"file":"",
"type":"pay"
},
fileTable:[],
fileList:[]
}
},
created() {
@@ -420,6 +476,50 @@
}
},
methods: {
handleChange(file, fileList) {
this.fileList = fileList.slice(-3);
},
showFile(id){
this.fileData["id"]=id;
this.showFileFlag = true
axios.post("/hotel.php/order_main/getFileList", this.fileData).then((response) => {
let data = response.data;
if (data.flag) {
this.fileTable = data.data
} else {
this.$message.error(response.msg);
}
}).catch(function (error) {
console.log(error);
});
},
handleExceed(files, fileList) {
this.$message.warning(`当前限制选择 1 个文件`);
},
fileSubmit(){
if (this.fileList.length==0) {
this.$message.error(`请选择文件`);
return false;
}
if (this.fileData["name"]=="") {
this.$message.error(`请输入名称标识`);
return false;
}
let file = this.fileList[0].response.data.url;
this.fileData["file"]=file;
axios.post("/hotel.php/order_main/addFileInfo", this.fileData).then((response) => {
let data = response.data;
if (data.flag) {
this.fileList=[]
this.showFile(this.fileData["id"])
} else {
this.$message.error(response.msg);
}
}).catch(function (error) {
console.log(error);
});

},
getTypeName(info) {
for (let i = 0; i < this.type_list.length; i++) {
if (this.type_list[i].id == info.hotel_name) {
@@ -716,6 +816,13 @@
})
</script>
<style lang="scss" scoped>
.upload .el-upload__input {
display: none !important;
}

input[type="file"] {
display: none !important;
}
.el-table thead {
background-color: #5a5e66 !important;
}


+ 111
- 3
application/admin/view/receipt_order/index.html View File

@@ -65,9 +65,10 @@
<el-table-column label="操作" min-width="180">
<template slot-scope="scope">
<el-button-group>
<el-button type="primary" size="mini" @click="edit(scope.row)" icon="el-icon-edit">编辑</el-button>
<el-button type="success" size="mini" @click="editOrderDivShow(scope.row)" icon="el-icon-share">订单</el-button>
<el-button type="danger" size="mini" icon="el-icon-delete" @click="delAll(scope.row.id)">删除</el-button>
<el-button type="primary" size="mini" @click="edit(scope.row)" icon="el-icon-edit" style="margin: 5px;">编辑</el-button>
<el-button type="success" size="mini" @click="editOrderDivShow(scope.row)" icon="el-icon-share" style="margin: 5px;">订单</el-button>
<el-button type="danger" size="mini" v-if="scope.row.status==0" icon="el-icon-delete" @click="delAll(scope.row.id)" style="margin: 5px;">删除</el-button>
<el-button type="danger" size="mini" icon="el-icon-search" @click="showFile(scope.row.id)" style="margin: 5px;">附件</el-button>
</el-button-group>
</template>
</el-table-column>
@@ -263,6 +264,53 @@
</div>
</el-dialog>
</transition>

<transition name="bounce" v-if="showFileFlag">
<el-dialog title="附件详情" :visible.sync="showFileFlag" width="90%" top="15px">
<el-form ref="form" label-width="100px" style="width: 100%;padding-bottom: 20px">
<div style="display: flex;width: 100%">
<el-form-item label="账单ID:" style="width: 80%">
<div v-html="fileData.id"></div>
</el-form-item>
</div>
<div>
<el-form-item label="名称标识:" style="width: 80%">
<el-input v-model="fileData.name" style="width: 120px;" placeholder="请输入内容" clearable></el-input>
</el-form-item>
</div>
<div>
<el-form-item label="文件:" style="width: 80%">
<div>
<el-upload
:multiple="false"
:limit="1"
class="upload-demo"
action="/hotel.php/ajax/upload"
:on-change="handleChange"
:on-exceed="handleExceed"
:file-list="fileList">
<el-button size="small" type="primary">点击上传</el-button>
</el-upload>
</div>
</el-form-item>
</div>
<div>
<el-button type="primary" @click="fileSubmit()" >提交</el-button>
</div>
</el-form>
<el-table ref="multipleTable" :data="fileTable" border tooltip-effect="dark" style="font-size:12px;width: 100%;margin-top: 12px">
<el-table-column prop="name" label="名称标识" min-width="140" ></el-table-column>
<el-table-column prop="create_name" label="创建人" min-width="70" ></el-table-column>
<el-table-column prop="create_time" label="创建时间" min-width="70" ></el-table-column>
<el-table-column label="点击下载" min-width="40" >
<template slot-scope="scope">
<el-link :href="scope.row.file" target="_blank" style="color: #0a568c">下载</el-link>
</template>
</el-table-column>

</el-table>
</el-dialog>
</transition>
</div>
</body>
<!-- import Vue before Element -->
@@ -364,6 +412,15 @@
}
}]
},
showFileFlag:false,
fileData:{
"id":"",
"name":"",
"file":"",
"type":"receipt"
},
fileTable:[],
fileList:[]
}
},
created() {
@@ -373,6 +430,50 @@

},
methods: {
handleChange(file, fileList) {
this.fileList = fileList.slice(-3);
},
showFile(id){
this.fileData["id"]=id;
this.showFileFlag = true
axios.post("/hotel.php/order_main/getFileList", this.fileData).then((response) => {
let data = response.data;
if (data.flag) {
this.fileTable = data.data
} else {
this.$message.error(response.msg);
}
}).catch(function (error) {
console.log(error);
});
},
handleExceed(files, fileList) {
this.$message.warning(`当前限制选择 1 个文件`);
},
fileSubmit(){
if (this.fileList.length==0) {
this.$message.error(`请选择文件`);
return false;
}
if (this.fileData["name"]=="") {
this.$message.error(`请输入名称标识`);
return false;
}
let file = this.fileList[0].response.data.url;
this.fileData["file"]=file;
axios.post("/hotel.php/order_main/addFileInfo", this.fileData).then((response) => {
let data = response.data;
if (data.flag) {
this.fileList=[]
this.showFile(this.fileData["id"])
} else {
this.$message.error(response.msg);
}
}).catch(function (error) {
console.log(error);
});

},
checkSelect(row,index){
if (this.editOrder.status != 0) {
return false;
@@ -609,6 +710,13 @@
})
</script>
<style lang="scss" scoped>
.upload .el-upload__input {
display: none !important;
}

input[type="file"] {
display: none !important;
}
.el-table thead {
background-color: #5a5e66 !important;
}


+ 8
- 8
application/common/library/Upload.php View File

@@ -90,15 +90,15 @@ class Upload

protected function checkMimetype()
{
$mimetypeArr = explode(',', strtolower($this->config['mimetype']));
$typeArr = explode('/', $this->fileInfo['type']);
//验证文件后缀
if ($this->config['mimetype'] === '*'
|| in_array($this->fileInfo['suffix'], $mimetypeArr) || in_array('.' . $this->fileInfo['suffix'], $mimetypeArr)
|| in_array($this->fileInfo['type'], $mimetypeArr) || in_array($typeArr[0] . "/*", $mimetypeArr)) {
// $mimetypeArr = explode(',', strtolower($this->config['mimetype']));
// $typeArr = explode('/', $this->fileInfo['type']);
// //验证文件后缀
// if ($this->config['mimetype'] === '*'
// || in_array($this->fileInfo['suffix'], $mimetypeArr) || in_array('.' . $this->fileInfo['suffix'], $mimetypeArr)
// || in_array($this->fileInfo['type'], $mimetypeArr) || in_array($typeArr[0] . "/*", $mimetypeArr)) {
return true;
}
throw new UploadException(__('Uploaded file format is limited'));
// }
// throw new UploadException(__('Uploaded file format is limited'));
}

protected function checkImage($force = false)


Loading…
Cancel
Save