|
@@ -1,15 +1,34 @@
|
|
|
<template>
|
|
|
<div class="my-container">
|
|
|
- <!-- <div class="bill-left">
|
|
|
- <div class="bill-tab">
|
|
|
- <div class="title">导航</div>
|
|
|
- <el-tree :data="data" :props="props" @node-click="handleNodeClick"></el-tree>
|
|
|
- </div>
|
|
|
- </div> -->
|
|
|
<div class="bill-main">
|
|
|
<module-view :propConfig="config" ref="moduleView" @pagination="getDataList" @search="getDataList"
|
|
|
- @resert="getDataList" @clickHandle="clickHandle" />
|
|
|
+ @resert="getDataList" @clickHandle="clickHandle">
|
|
|
+ <template v-slot:status="{ value }">
|
|
|
+ <!-- <el-tag :type="value.row.status===0?'primary':'danger'"
|
|
|
+ disable-transitions>{{value.row.status===0?'正常':'禁用'}}</el-tag> -->
|
|
|
+ <div>{{value}}</div>
|
|
|
+ </template>
|
|
|
+ </module-view>
|
|
|
</div>
|
|
|
+ <!-- 新增/编辑弹窗 -->
|
|
|
+ <el-dialog :title="popTitle+'品牌'" :visible.sync="dialogFormVisible" width="30%">
|
|
|
+ <by-form :propConfig="addConfig" ref="addFormId">
|
|
|
+ <template v-slot:logo>
|
|
|
+ <el-upload :limit='1' :action="baseURL+'/file/upload'" list-type="picture-card"
|
|
|
+ :on-preview="handlePictureCardPreview" :on-remove="handleRemove">
|
|
|
+ <i class="el-icon-plus"></i>
|
|
|
+ </el-upload>
|
|
|
+ </template>
|
|
|
+ <template v-slot:status class="clearfix">
|
|
|
+ <el-radio class="fl" style="margin-top: 8px;" v-model="radio" :label="0">显示</el-radio>
|
|
|
+ <el-radio class="fl" style="margin-top: 8px;" v-model="radio" :label="1">禁用</el-radio>
|
|
|
+ </template>
|
|
|
+ </by-form>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="dialogFormVisible = false">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="confirm">确 定</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script lang="ts">
|
|
@@ -17,13 +36,12 @@
|
|
|
import api from "@/api/currency";
|
|
|
@Component
|
|
|
export default class Brand extends Vue {
|
|
|
+ baseURL : any = process.env.VUE_APP_BASE_API
|
|
|
timeNum = 0;
|
|
|
timer : any = null
|
|
|
- data : any = []
|
|
|
- props = {
|
|
|
- label: 'name',
|
|
|
- children: 'children'
|
|
|
- }
|
|
|
+ popTitle : any = ''
|
|
|
+ radio : any = 0
|
|
|
+ dialogFormVisible : boolean = false
|
|
|
config : any = {
|
|
|
search: {
|
|
|
attr: {
|
|
@@ -85,7 +103,13 @@
|
|
|
]
|
|
|
},
|
|
|
tool: {
|
|
|
- tools: this.getTools()
|
|
|
+ tools: {
|
|
|
+ add: true,
|
|
|
+ export: true,
|
|
|
+ delete: true,
|
|
|
+ search: true,
|
|
|
+ refresh: true
|
|
|
+ }
|
|
|
},
|
|
|
table: {
|
|
|
attr: {
|
|
@@ -104,29 +128,16 @@
|
|
|
field: 'shortName',
|
|
|
width: 100
|
|
|
}, {
|
|
|
- title: '财务编号',
|
|
|
- field: 'accountingCode'
|
|
|
- }, {
|
|
|
- title: '国际码',
|
|
|
- field: 'nsCode'
|
|
|
- }, {
|
|
|
- title: '基本售价',
|
|
|
- field: 'basePrice'
|
|
|
- }, {
|
|
|
- title: '市场价格(统一售价)',
|
|
|
- field: 'markPrice'
|
|
|
+ title: '品牌logo',
|
|
|
+ field: 'logo'
|
|
|
}, {
|
|
|
- title: '单位',
|
|
|
- field: 'unit'
|
|
|
+ title: '状态',
|
|
|
+ field: 'status',
|
|
|
+ slot: true,
|
|
|
+ prop: 'status',
|
|
|
}, {
|
|
|
- title: '重量',
|
|
|
- field: 'weight'
|
|
|
- }, {
|
|
|
- title: '保质期(天)',
|
|
|
- field: 'shelfLife'
|
|
|
- }, {
|
|
|
- title: '库存',
|
|
|
- field: 'stock'
|
|
|
+ title: '备注',
|
|
|
+ field: 'remark'
|
|
|
}, {
|
|
|
title: '操作',
|
|
|
action: true,
|
|
@@ -136,32 +147,101 @@
|
|
|
audit: '',
|
|
|
event: {
|
|
|
click: (item : any) => {
|
|
|
- console.log('该行数据:', item)
|
|
|
+ (this as any).openEdit(item)
|
|
|
}
|
|
|
}
|
|
|
}, {
|
|
|
name: '删除',
|
|
|
event: {
|
|
|
- click: (item : any) => this.onDelete(item)
|
|
|
+ click: (item : any) => (this as any).doDelete2(item)
|
|
|
}
|
|
|
}]
|
|
|
}]
|
|
|
},
|
|
|
}
|
|
|
- getTools() {
|
|
|
- return {
|
|
|
- add: true,
|
|
|
- export: true,
|
|
|
- delete: true,
|
|
|
- search: true,
|
|
|
- refresh: true
|
|
|
- }
|
|
|
+ addConfig = {
|
|
|
+ attr: {
|
|
|
+ size: 'small',
|
|
|
+ rules: {
|
|
|
+ name: [{
|
|
|
+ required: true, message: '请输入名称', trigger: 'blur'
|
|
|
+ }],
|
|
|
+ shortName: [{
|
|
|
+ required: true, message: '请输入简称', trigger: 'blur'
|
|
|
+ }]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ columns: [
|
|
|
+ [
|
|
|
+ {
|
|
|
+ span: 20,
|
|
|
+ label: '名称',
|
|
|
+ prop: 'name',
|
|
|
+ component: 'by-input',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ span: 20,
|
|
|
+ label: '简称',
|
|
|
+ prop: 'shortName',
|
|
|
+ component: 'by-input',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ span: 20,
|
|
|
+ label: '品牌logo',
|
|
|
+ slot: true,
|
|
|
+ prop: 'logo',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ span: 20,
|
|
|
+ label: '显示状态',
|
|
|
+ slot: true,
|
|
|
+ prop: 'status',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ {
|
|
|
+ span: 20,
|
|
|
+ label: '备注',
|
|
|
+ prop: 'remark',
|
|
|
+ component: 'by-input',
|
|
|
+ },
|
|
|
+ ]
|
|
|
+ ]
|
|
|
}
|
|
|
created() {
|
|
|
this.timer = setInterval(() => {
|
|
|
this.getDataList()
|
|
|
}, 500)
|
|
|
}
|
|
|
+ // 确认新增/编辑
|
|
|
+ confirm() {
|
|
|
+ (this as any).$refs.addFormId.validate().then(() => {
|
|
|
+ let query = (this as any).$refs.addFormId.getValue();
|
|
|
+ query.status = this.radio;
|
|
|
+ this.dialogFormVisible = false;
|
|
|
+ if (this.popTitle === '新增') {
|
|
|
+ api.saveList(query, 'maindataMaterialBrand').then((res : any) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.$message({
|
|
|
+ type: 'success',
|
|
|
+ message: this.popTitle + '成功!'
|
|
|
+ });
|
|
|
+ this.getDataList();
|
|
|
+ } else this.failHandle(res)
|
|
|
+ })
|
|
|
+ } else if (this.popTitle === '编辑') {
|
|
|
+ api.updateList(query, 'maindataMaterialBrand').then((res : any) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.$message({
|
|
|
+ type: 'success',
|
|
|
+ message: this.popTitle + '成功!'
|
|
|
+ });
|
|
|
+ this.getDataList();
|
|
|
+ } else this.failHandle(res)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
// 获取列表数据
|
|
|
getDataList() {
|
|
|
if (!this.$refs.moduleView) {
|
|
@@ -187,19 +267,49 @@
|
|
|
}
|
|
|
// 工具栏方法
|
|
|
clickHandle(e : any) {
|
|
|
- console.log(e);
|
|
|
if (e === 'onRefresh') (this.$refs.moduleView as any).resert();
|
|
|
if (e === 'onAdd') this.onAdd();
|
|
|
- // if (e === 'onDelete') this.onDelete(e);
|
|
|
+ if (e === 'onDelete') this.onDelete();
|
|
|
if (e === 'onExport') this.onExport();
|
|
|
}
|
|
|
- // 新增
|
|
|
+ // 打开新增
|
|
|
onAdd() {
|
|
|
-
|
|
|
- (this as any).$router.push('/materialFile/detail')
|
|
|
+ this.popTitle = '新增'
|
|
|
+ this.dialogFormVisible = true;
|
|
|
+ setTimeout(() => {
|
|
|
+ if ((this as any).$refs.addFormId) (this as any).$refs.addFormId.setValue({});
|
|
|
+ }, 0)
|
|
|
}
|
|
|
- // 删除
|
|
|
- onDelete(item : any) {
|
|
|
+ // 打开编辑
|
|
|
+ openEdit(e : any) {
|
|
|
+ this.popTitle = '编辑'
|
|
|
+ this.dialogFormVisible = true;
|
|
|
+ setTimeout(() => {
|
|
|
+ if ((this as any).$refs.addFormId) (this as any).$refs.addFormId.setValue(e);
|
|
|
+ }, 0)
|
|
|
+ }
|
|
|
+ // 工具栏删除
|
|
|
+ onDelete() {
|
|
|
+ let selectData = (this.$refs.moduleView as any).getSelectData()
|
|
|
+ let ids = '';
|
|
|
+ if (selectData.length > 0) {
|
|
|
+ selectData.map((v : any) => {
|
|
|
+ ids += v.id + ','
|
|
|
+ })
|
|
|
+ } else return this.$message({ type: 'warning', message: '请选择删除数据' })
|
|
|
+ ids = ids.slice(0, ids.length - 1);
|
|
|
+ api.deleteList({ ids: ids }, 'maindataMaterialBrand').then((res : any) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.getDataList();
|
|
|
+ this.$message({
|
|
|
+ type: 'success',
|
|
|
+ message: '删除成功!'
|
|
|
+ });
|
|
|
+ } else this.failHandle(res)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ // 操作删除
|
|
|
+ doDelete2(item : any) {
|
|
|
api.deleteList({ ids: item.id }, 'maindataMaterialBrand').then((res : any) => {
|
|
|
if (res.code === 200) {
|
|
|
this.getDataList();
|
|
@@ -210,6 +320,12 @@
|
|
|
} else this.failHandle(res)
|
|
|
})
|
|
|
}
|
|
|
+ handleRemove(file : any, fileList : any) {
|
|
|
+ console.log(file, fileList);
|
|
|
+ }
|
|
|
+ handlePictureCardPreview(file : any) {
|
|
|
+ console.log(file);
|
|
|
+ }
|
|
|
//导出
|
|
|
onExport() {
|
|
|
let urlArr = '/maindata/maindataMaterial';
|