Explorar o código

系统设置-打印模板

WIN-B904R0U0NNS\Administrator %!s(int64=2) %!d(string=hai) anos
pai
achega
c772a9bc30

+ 208 - 0
src/views/settings/components/modules/printTemplateForm.vue

@@ -0,0 +1,208 @@
+<template>
+  <a-spin :spinning="confirmLoading">
+    <div class="container">
+      <div class="left">
+        <j-form-container :disabled="formDisabled">
+          <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail" layout="vertical">
+            <a-row >
+              <a-col :span="24">
+                <a-form-model-item label="模板名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="name">
+                  <a-input v-model="model.name" placeholder="请输入打印模板名称"  ></a-input>
+                </a-form-model-item>
+              </a-col>
+              <a-col :span="24">
+                <a-form-model-item label="规格" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="specs">
+                  <j-dict-select-tag type="radio" v-model="model.specs" placeholder="请选择规格" dictCode="print_template_specs"
+                                     @change="e=>onSpecsChange(e)"/>
+                </a-form-model-item>
+              </a-col>
+              <a-col :span="24">
+                <a-form-model-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remarks">
+                  <a-textarea :rows="4" v-model="model.remarks" placeholder="请输入备注"/>
+                </a-form-model-item>
+              </a-col>
+              <a-col :span="24">
+                <a-form-model-item label="" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="preview">
+                  <a-checkbox v-model="model.preview">不显示打印预览窗口,直接打印小票</a-checkbox>
+                </a-form-model-item>
+              </a-col>
+
+              <a-col :span="24">
+                <a-form-model-item label="默认打印机" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="defaultPrint">
+                  <a-input v-model="model.defaultPrint" placeholder="请输入默认打印机"  ></a-input>
+                </a-form-model-item>
+              </a-col>
+              <a-col :span="24">
+                <a-form-model-item label="打印类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="printType">
+                  <j-dict-select-tag type="radio" v-model="model.printType" placeholder="请选择打印类型" dictCode="print_template_type"/>
+                </a-form-model-item>
+              </a-col>
+              <a-col :span="24">
+                <a-form-model-item label="是否显示退菜" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="isShowRefund">
+                  <j-dict-select-tag type="radio" v-model="model.isShowRefund" placeholder="请选择是否显示退菜" dictCode="print_template_refund"/>
+                </a-form-model-item>
+              </a-col>
+              <a-col :span="24">
+                <a-form-model-item label="打印份数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="printSum">
+                  <a-input-number v-model="model.printSum" placeholder="请输入打印份数" style="width: 100%" />
+                </a-form-model-item>
+              </a-col>
+              <a-col :span="24">
+                <a-form-model-item label="打印时内容宽度偏差" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="printContentOffset">
+                  <a-input v-model="model.printContentOffset" placeholder="请输入打印时内容宽度偏差"  ></a-input>
+                </a-form-model-item>
+              </a-col>
+              <a-col :span="24">
+                <a-form-model-item label="打印时纸张宽度偏差" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="printPaperOffset">
+                  <a-input v-model="model.printPaperOffset" placeholder="请输入打印时纸张宽度偏差"  ></a-input>
+                </a-form-model-item>
+              </a-col>
+            </a-row>
+          </a-form-model>
+        </j-form-container>
+      </div>
+      <div class="right">
+        <a-card class="template" :style="{width:width}">
+          <p>Card content</p>
+          <p>Card content</p>
+          <p>Card content</p>
+        </a-card>
+      </div>
+    </div>
+
+  </a-spin>
+</template>
+
+<script>
+
+  import { httpAction, getAction } from '@/api/manage'
+  import { validateDuplicateValue } from '@/utils/util'
+
+  export default {
+    name: 'printTemplateForm',
+    components: {
+    },
+    props: {
+      //表单禁用
+      disabled: {
+        type: Boolean,
+        default: false,
+        required: false
+      }
+    },
+    data () {
+      return {
+        model:{
+         },
+        labelCol: {
+        },
+        wrapperCol: {
+        },
+        confirmLoading: false,
+        validatorRules: {
+           name: [
+              { required: true, message: '请输入打印模板名称!'},
+           ],
+           specs: [
+              { required: true, message: '请输入规格!'},
+           ],
+          remarks: [
+            { required: true, message: '请输入备注!'},
+          ],
+          printSum: [
+            { required: true, message: '请输入打印份数!'},
+          ],
+          printContentOffset: [
+            { required: true, message: '请输入打印时内容宽度偏差!'},
+          ],
+          printPaperOffset: [
+            { required: true, message: '请输入打印时纸张宽度偏差!'},
+          ],
+        },
+        url: {
+          add: "/business/busPrintTemplate/add",
+          edit: "/business/busPrintTemplate/edit",
+          queryById: "/business/busPrintTemplate/queryById"
+        },
+        width:"94%"
+      }
+    },
+    computed: {
+      formDisabled(){
+        return this.disabled
+      },
+    },
+    created () {
+       //备份model原始值
+      this.modelDefault = JSON.parse(JSON.stringify(this.model));
+    },
+    methods: {
+      add () {
+        this.edit(this.modelDefault);
+      },
+      edit (record) {
+        this.model = Object.assign({}, record);
+        this.width = record.specs;
+        if (record.specs === 'A5'){
+          // this.width = '210mm';
+        }
+        this.visible = true;
+      },
+      submitForm () {
+        const that = this;
+        // 触发表单验证
+        this.$refs.form.validate(valid => {
+          if (valid) {
+            that.confirmLoading = true;
+            let httpurl = '';
+            let method = '';
+            if(!this.model.id){
+              httpurl+=this.url.add;
+              method = 'post';
+              var info = JSON.parse(localStorage.getItem("storeInfo"));
+              this.model.hotelId = info.id;
+            }else{
+              httpurl+=this.url.edit;
+               method = 'put';
+            }
+            httpAction(httpurl,this.model,method).then((res)=>{
+              if(res.success){
+                that.$message.success(res.message);
+                that.$emit('ok');
+              }else{
+                that.$message.warning(res.message);
+              }
+            }).finally(() => {
+              that.confirmLoading = false;
+            })
+          }
+
+        })
+      },
+      onSpecsChange(val){
+        console.log('规格切换  ————  '+val)
+        this.width = val;
+        console.log(this.width)
+        if (val === 'A5'){
+          // this.width = '210mm';
+        }
+      }
+    }
+  }
+</script>
+
+<style lang="less" scoped>
+  .container{
+    display: flex;
+    flex-direction: row;
+  }
+  .left{
+    flex: 2;
+  }
+  .right{
+    flex: 3;
+  }
+  .template{
+    margin-left: 10px;
+  }
+</style>

+ 84 - 0
src/views/settings/components/modules/printTemplateModal.Style#Drawer.vue

@@ -0,0 +1,84 @@
+<template>
+  <a-drawer
+    :title="title"
+    :width="width"
+    placement="right"
+    :closable="false"
+    @close="close"
+    destroyOnClose
+    :visible="visible">
+    <print-template-form ref="realForm" @ok="submitCallback" :disabled="disableSubmit" normal></print-template-form>
+    <div class="drawer-footer">
+      <a-button @click="handleCancel" style="margin-bottom: 0;">关闭</a-button>
+      <a-button v-if="!disableSubmit"  @click="handleOk" type="primary" style="margin-bottom: 0;">提交</a-button>
+    </div>
+  </a-drawer>
+</template>
+
+<script>
+
+  import printTemplateForm from './printTemplateForm'
+
+  export default {
+    name: 'printTemplateModal',
+    components: {
+      printTemplateForm,
+    },
+    data () {
+      return {
+        title:"操作",
+        width:800,
+        visible: false,
+        disableSubmit: false
+      }
+    },
+    methods: {
+      add () {
+        this.visible=true
+        this.$nextTick(()=>{
+          this.$refs.realForm.add();
+        })
+      },
+      edit (record) {
+        this.visible=true
+        this.$nextTick(()=>{
+          this.$refs.realForm.edit(record);
+        });
+      },
+      close () {
+        this.$emit('close');
+        this.visible = false;
+      },
+      submitCallback(){
+        this.$emit('ok');
+        this.visible = false;
+      },
+      handleOk () {
+        this.$refs.realForm.submitForm();
+      },
+      handleCancel () {
+        this.close()
+      }
+    }
+  }
+</script>
+
+<style lang="less" scoped>
+/** Button按钮间距 */
+  .ant-btn {
+    margin-left: 30px;
+    margin-bottom: 30px;
+    float: right;
+  }
+  .drawer-footer{
+    position: absolute;
+    bottom: -8px;
+    width: 100%;
+    border-top: 1px solid #e8e8e8;
+    padding: 10px 16px;
+    text-align: right;
+    left: 0;
+    background: #fff;
+    border-radius: 0 0 2px 2px;
+  }
+</style>

+ 60 - 0
src/views/settings/components/modules/printTemplateModal.vue

@@ -0,0 +1,60 @@
+<template>
+  <j-modal
+    :title="title"
+    :width="width"
+    :visible="visible"
+    switchFullscreen
+    @ok="handleOk"
+    :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
+    @cancel="handleCancel"
+    cancelText="关闭">
+    <print-template-form ref="realForm" @ok="submitCallback" :disabled="disableSubmit"></print-template-form>
+  </j-modal>
+</template>
+
+<script>
+
+  import printTemplateForm from './printTemplateForm'
+  export default {
+    name: 'printTemplateModal',
+    components: {
+      printTemplateForm
+    },
+    data () {
+      return {
+        title:'',
+        width:1200,
+        visible: false,
+        disableSubmit: false
+      }
+    },
+    methods: {
+      add () {
+        this.visible=true
+        this.$nextTick(()=>{
+          this.$refs.realForm.add();
+        })
+      },
+      edit (record) {
+        this.visible=true
+        this.$nextTick(()=>{
+          this.$refs.realForm.edit(record);
+        })
+      },
+      close () {
+        this.$emit('close');
+        this.visible = false;
+      },
+      handleOk () {
+        this.$refs.realForm.submitForm();
+      },
+      submitCallback(){
+        this.$emit('ok');
+        this.visible = false;
+      },
+      handleCancel () {
+        this.close()
+      }
+    }
+  }
+</script>

+ 203 - 4
src/views/settings/components/printTemplate.vue

@@ -1,13 +1,212 @@
 <template>
-    <div>打印模板</div>
+    <a-card :bordered="false">
+        <!-- 查询区域 -->
+        <div class="table-page-search-wrapper">
+            <a-form layout="inline" @keyup.enter.native="searchQuery">
+                <a-row :gutter="24">
+                    <a-col :md="4" :sm="6">
+                        <a-form-item>
+                            <j-input placeholder="参数名" v-model="queryParam.name"></j-input>
+                        </a-form-item>
+                    </a-col>
+                    <a-col :md="4" :sm="6">
+                        <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
+                          <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
+                        </span>
+                    </a-col>
+                </a-row>
+            </a-form>
+        </div>
+        <!-- 查询区域-END -->
+
+        <!-- 操作按钮区域 -->
+        <div class="table-operator">
+            <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
+<!--            <a-button type="primary" icon="download" @click="handleExportXls('打印模板')">导出</a-button>-->
+<!--            <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">-->
+<!--                <a-button type="primary" icon="import">导入</a-button>-->
+<!--            </a-upload>-->
+<!--            &lt;!&ndash; 高级查询区域 &ndash;&gt;-->
+<!--            <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>-->
+<!--            <a-dropdown v-if="selectedRowKeys.length > 0">-->
+<!--                <a-menu slot="overlay">-->
+<!--                    <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>-->
+<!--                </a-menu>-->
+<!--                <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>-->
+<!--            </a-dropdown>-->
+        </div>
+
+        <!-- table区域-begin -->
+        <div>
+            <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
+                <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
+                <a style="margin-left: 24px" @click="onClearSelected">清空</a>
+            </div>
+
+            <a-table
+                    ref="table"
+                    size="middle"
+                    :scroll="{x:true}"
+                    bordered
+                    rowKey="id"
+                    :columns="columns"
+                    :dataSource="dataSource"
+                    :pagination="ipagination"
+                    :loading="loading"
+                    :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
+                    class="j-table-force-nowrap"
+                    @change="handleTableChange">
+
+                <template slot="htmlSlot" slot-scope="text">
+                    <div v-html="text"></div>
+                </template>
+                <template slot="imgSlot" slot-scope="text,record">
+                    <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
+                    <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
+                </template>
+                <template slot="fileSlot" slot-scope="text">
+                    <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
+                    <a-button
+                            v-else
+                            :ghost="true"
+                            type="primary"
+                            icon="download"
+                            size="small"
+                            @click="downloadFile(text)">
+                        下载
+                    </a-button>
+                </template>
+
+                <span slot="action" slot-scope="text, record">
+          <a @click="handleEdit(record)">编辑</a>
+
+<!--          <a-divider type="vertical" />-->
+<!--          <a-dropdown>-->
+<!--            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>-->
+<!--            <a-menu slot="overlay">-->
+<!--              <a-menu-item>-->
+<!--                <a @click="handleDetail(record)">详情</a>-->
+<!--              </a-menu-item>-->
+<!--              <a-menu-item>-->
+<!--                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">-->
+<!--                  <a>删除</a>-->
+<!--                </a-popconfirm>-->
+<!--              </a-menu-item>-->
+<!--            </a-menu>-->
+<!--          </a-dropdown>-->
+        </span>
+
+            </a-table>
+        </div>
+
+        <print-template-modal ref="modalForm" @ok="modalFormOk"></print-template-modal>
+    </a-card>
 </template>
 
 <script>
+
+    import '@/assets/less/TableExpand.less'
+    import { mixinDevice } from '@/utils/mixin'
+    import { JeecgListMixin } from '@/mixins/JeecgListMixin'
+    import printTemplateModal from "./modules/printTemplateModal";
+
     export default {
-        name: "printTemplate"
+        name: 'printTemplate',
+        mixins:[JeecgListMixin, mixinDevice],
+        components: {
+            printTemplateModal,
+        },
+        data () {
+            return {
+                description: '打印模板管理页面',
+                // 表头
+                columns: [
+                    {
+                        title: '',
+                        dataIndex: '',
+                        key:'rowIndex',
+                        width:60,
+                        align:"center",
+                        customRender:function (t,r,index) {
+                            return parseInt(index)+1;
+                        }
+                    },
+                    {
+                        title:'打印单据名',
+                        align:"center",
+                        dataIndex: 'name'
+                    },
+                    {
+                        title:'规格',
+                        align:"center",
+                        dataIndex: 'specs'
+                    },
+                    {
+                        title:'打印份数',
+                        align:"center",
+                        dataIndex: 'printSum'
+                    },
+                    {
+                        title:'打印时内容宽度偏差',
+                        align:"center",
+                        dataIndex: 'printContentOffset'
+                    },
+                    {
+                        title:'打印时纸张宽度偏差',
+                        align:"center",
+                        dataIndex: 'printPaperOffset'
+                    },
+                    {
+                        title: '操作',
+                        dataIndex: 'action',
+                        align:"center",
+                        fixed:"right",
+                        width:147,
+                        scopedSlots: { customRender: 'action' }
+                    }
+                ],
+                url: {
+                    list: "/business/busPrintTemplate/list",
+                    delete: "/business/busPrintTemplate/delete",
+                    deleteBatch: "/business/busPrintTemplate/deleteBatch",
+                    exportXlsUrl: "/business/busPrintTemplate/exportXls",
+                    importExcelUrl: "business/busPrintTemplate/importExcel",
+
+                },
+                dictOptions:{},
+                superFieldList:[],
+            }
+        },
+        created() {
+            this.getSuperFieldList();
+        },
+        computed: {
+            importExcelUrl: function(){
+                return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
+            },
+        },
+        methods: {
+            initDictConfig(){
+            },
+            getSuperFieldList(){
+                let fieldList=[];
+                fieldList.push({type:'string',value:'tenantId',text:'关联租户'})
+                fieldList.push({type:'string',value:'hotelId',text:'关联酒店'})
+                fieldList.push({type:'string',value:'name',text:'打印模板名称'})
+                fieldList.push({type:'string',value:'specs',text:'规格'})
+                fieldList.push({type:'string',value:'remarks',text:'备注'})
+                fieldList.push({type:'string',value:'defaultPrint',text:'默认打印机'})
+                fieldList.push({type:'int',value:'printType',text:'打印类型(1-明细;2-汇总)'})
+                fieldList.push({type:'int',value:'printSum',text:'打印份数'})
+                fieldList.push({type:'string',value:'preview',text:'打印预览'})
+                fieldList.push({type:'string',value:'printContentOffset',text:'打印时内容宽度偏差'})
+                fieldList.push({type:'string',value:'printPaperOffset',text:'打印时纸张宽度偏差'})
+                fieldList.push({type:'int',value:'isShowRefund',text:'状态(0-关闭;1-开启)'})
+                this.superFieldList = fieldList
+            }
+        }
     }
 </script>
-
 <style scoped>
-
+    @import '~@assets/less/common.less';
 </style>