123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462 |
- <template>
- <div class="my-container">
- <div class="bill-main">
- <module-view :propConfig="config" ref="moduleView" @pagination="getDataList" @search="getDataList"
- @resert="getDataList" @clickHandle="clickHandle" @detail="openEdit" @onRefresh="onRefresh">
- </module-view>
- </div>
- <!-- 新增/编辑弹窗 -->
- <el-dialog :title="popTitle+'品牌'" :visible.sync="dialogFormVisible" width="30%">
- <by-form :propConfig="addConfig" ref="addFormId">
- <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">
- import { Component, Prop, Vue, Watch } from "vue-property-decorator";
- import api from "@/api/currency";
- import Assembly from "@/components/Assembly/material.vue";
- @Component
- export default class Brand extends Vue {
- baseURL : any = process.env.VUE_APP_BASE_API
- loading : any = null
- timeNum = 0;
- timer : any = null
- popTitle : any = ''
- radio : any = 0
- dialogFormVisible : boolean = false
- config : any = {
- search: {
- attr: {
- size: 'mini'
- },
- columns: [
- [{
- span: 6,
- label: '名称',
- prop: 'name',
- component: 'by-input',
- labelWidth: '70px',
- compConfig: {
- attr: {
- placeholder: '请输入名称',
- clearable: true
- },
- },
- }, {
- span: 6,
- label: '简称',
- prop: 'shortName',
- component: 'by-input',
- labelWidth: '70px',
- compConfig: {
- attr: {
- placeholder: '请输入简称',
- clearable: true
- }
- }
- },
- {
- span: 6,
- label: '状态',
- prop: 'status',
- labelWidth: '70px',
- component: 'by-select',
- compConfig: {
- attr: {
- placeholder: '请选择状态',
- clearable: true,
- data: [{
- value: 0,
- label: '正常'
- }, {
- value: 1,
- label: '禁用'
- }]
- }
- }
- },
- ]
- ]
- },
- tool: {
- tools: {
- add: true,
- delete: true,
- search: true,
- refresh: true
- }
- },
- table: {
- attr: {
- size: 'mini',
- seq: true,
- align: 'center',
- checkbox: true,
- height: 600
- },
- columns: [{
- title: '名称',
- field: 'name',
- isDetail: true,
- width: 300,
- }, {
- title: '简称',
- field: 'shortName',
- width: 300,
- },
- {
- width: 80,
- title: '状态',
- field: 'status',
- component: Assembly,
- }, {
- width: 500,
- title: '备注',
- field: 'remark',
- }, {
- width: 120,
- title: '操作',
- action: true,
- plugins: [{
- icon: 'el-icon-edit',
- name: '编辑',
- audit: '',
- event: {
- click: (item : any) => {
- (this as any).openEdit(item)
- }
- }
- }, {
- name: '删除',
- event: {
- click: (item : any) => (this as any).doDelete2(item)
- }
- }]
- }]
- },
- }
- addConfig = {
- attr: {
- size: 'small',
- rules: {
- name: [{
- required: true, message: '请输入名称', trigger: 'blur'
- }],
- shortName: [{
- required: true, message: '请输入简称', trigger: 'blur'
- }]
- }
- },
- columns: [
- [
- {
- span: 23,
- labelWidth: '70px',
- label: '名称',
- prop: 'name',
- component: 'by-input',
- },
- {
- span: 23,
- labelWidth: '70px',
- label: '简称',
- prop: 'shortName',
- component: 'by-input',
- },
- {
- span: 23,
- labelWidth: '70px',
- label: '状态',
- slot: true,
- prop: 'status',
- },
- ],
- [
- {
- span: 23,
- labelWidth: '70px',
- label: '备注',
- prop: 'remark',
- component: 'by-input',
- compConfig: {
- attr: {
- size: 'mini',
- placeholder: '请输入备注',
- type:'textarea'
- },
- }
- },
- ]
- ]
- }
- mounted() {
- this.timer = setInterval(() => {
- this.getDataList()
- }, 300)
- }
- // 确认新增/编辑
- confirm() {
- (this as any).$refs.addFormId.validate().then(() => {
- let query = (this as any).$refs.addFormId.getValue();
- console.log(query);
- query.status = this.radio;
- this.dialogFormVisible = false;
- if (this.popTitle === '新增') {
- api.saveList(query, 'maindataMaterialBrand').then((res : any) => {
- if (res.code === 200) {
- this.$message.success(this.popTitle + '成功!');
- this.getDataList();
- } else this.$message.error(res.msg);
- })
- } 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.$message.error(res.msg);
- })
- }
- })
- }
- // 获取列表数据
- getDataList() {
- if (!this.$refs.moduleView) {
- if (this.timeNum > 5) {
- clearInterval(this.timer)
- }
- this.timeNum++;
- return
- }
- clearInterval(this.timer)
- let query = (this.$refs.moduleView as any).getQuery();
- api.pageList(query, 'maindataMaterialBrand').then((res : any) => {
- if (res.code === 200) {
- (this.$refs.moduleView as any).setTableValue(res.data.records);
- let page = {
- pageNo: res.data.current, //当前页
- pageSize: res.data.size, //每页条数
- total: res.data.total //总条数
- };
- (this.$refs.moduleView as any).setPage(page)
- } else this.$message.error(res.msg);
- })
- }
- // 工具栏方法
- clickHandle(e : any) {
- if (e === 'onAdd') this.onAdd();
- if (e === 'onDelete') this.onDelete();
- if (e === 'onExport') this.onExport();
- }
- // 打开新增
- onAdd() {
- this.popTitle = '新增'
- this.dialogFormVisible = true;
- this.radio = 0
- setTimeout(() => {
- if ((this as any).$refs.addFormId) (this as any).$refs.addFormId.setValue('');
- }, 0)
- }
- // 打开编辑
- openEdit(e : any) {
- this.popTitle = '编辑'
- this.dialogFormVisible = true;
- this.radio = e.status
- 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);
- this.$confirm('确定删除吗,此操作不能撤销!', '注意', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- center: true
- }).then(() => {
- api.deleteList({ ids: ids }, 'maindataMaterialBrand').then((res : any) => {
- if (res.code === 200) {
- this.getDataList();
- this.$message({
- type: 'success',
- message: '删除成功!'
- });
- } else this.$message.error(res.msg);
- })
- }).catch(() => {
- this.$message({
- type: 'info',
- message: '已取消删除'
- });
- });
- }
- // 操作删除
- doDelete2(item : any) {
- this.$confirm('确定删除吗,此操作不能撤销!', '注意', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- center: true
- }).then(() => {
- api.deleteList({ ids: item.id }, 'maindataMaterialBrand').then((res : any) => {
- if (res.code === 200) {
- this.getDataList();
- this.$message({
- type: 'success',
- message: '删除成功!'
- });
- } else this.$message.error(res.msg);
- })
- }).catch(() => {
- this.$message.info('已取消删除');
- });
- }
- // 刷新
- onRefresh(){
- this.loading = this.$loading({ target: '.main-container' });
- (this as any).$refs.moduleView.clearSearch();
- api.pageList({}, 'maindataMaterialBrand').then((res : any) => {
- if (res.code === 200) {
- (this.$refs.moduleView as any).setTableValue(res.data.records);
- let page = {
- pageNo: res.data.current, //当前页
- pageSize: res.data.size, //每页条数
- total: res.data.total //总条数
- };
- (this.$refs.moduleView as any).setPage(page);
- this.loading.close();
- } else this.$message.error(res.msg);
- })
- }
- //导出
- onExport() {
- let urlArr = '/maindata/maindataMaterial';
- let query = (this.$refs.moduleView as any).getQuery();
- (this as any).$download(urlArr + '/export', {
- ...query
- }, urlArr[urlArr.length - 1] + `_${new Date().getTime()}.xlsx`)
- }
- }
- </script>
- <style lang="scss" scoped>
- .my-container {
- width: 100%;
- box-sizing: border-box;
- display: flex;
- padding: 16px;
- .search-btn {
- width: 100%;
- display: flex;
- justify-content: flex-end;
- margin-bottom: 20px;
- }
- .bill-left {
- position: relative;
- border-right: solid #EEE 1px;
- padding-right: 16px;
- flex-shrink: 0;
- // box-sizing: border-box;
- .bill-tab {
- width: 150px;
- height: 100%;
- transition: all .5s;
- overflow: hidden;
- }
- .title {
- font-size: 16px;
- padding-bottom: 16px;
- width: 200px;
- }
- .bill-nav {
- font-size: 14px;
- height: 30px;
- line-height: 30px;
- width: 200px;
- box-sizing: border-box;
- padding: 0 8px;
- cursor: pointer;
- margin-bottom: 2px;
- border-radius: 5px;
- }
- .onBill {
- background-color: #bde3f7;
- }
- .bill-nav:hover {
- background-color: #bde3f7;
- }
- .close {
- height: 22px;
- width: 22px;
- border-radius: 50%;
- border: solid #EEE 1px;
- position: absolute;
- top: 30px;
- right: -11px;
- background-color: #FFF;
- display: flex;
- justify-content: center;
- align-items: center;
- cursor: pointer;
- }
- }
- .bill-main {
- width: calc(100% - 16px);
- box-sizing: border-box;
- margin-left: 16px;
- position: relative;
- .bill-box {
- width: 100%;
- position: absolute;
- left: 0;
- top: 0;
- opacity: 0;
- z-index: -1;
- transition: all .5s;
- .bill-tool,
- .table-tool {
- width: 100%;
- padding-bottom: 16px;
- }
- .form {
- margin-bottom: 8px;
- }
- }
- .on-show {
- opacity: 1;
- z-index: 1;
- }
- }
- }
- </style>
|