123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- <template>
- <div>
- <basic-container>
- <avue-crud
- :option="option"
- :data="dataList"
- ref="crud"
- v-model="form"
- :page.sync="page"
- :search.sync="search"
- @search-change="searchChange"
- @current-change="currentChange"
- @size-change="sizeChange"
- @refresh-change="refreshChange"
- @on-load="onLoad"
- :table-loading="loading"
- >
- <template slot="moudleNameSearch">
- <el-select
- v-model="search.moudleName"
- clearable
- filterable
- >
- <el-option
- v-for="(item, index) in moudleOption"
- :label="item.label"
- :value="item.value"
- :key="item.value"
- ></el-option>
- </el-select>
- </template>
- <template slot-scope="scope" slot="moudleName">
- <span>{{ scope.row.moudleName | moudleNameFormat(moudleOption) }}</span>
- </template>
- <template slot="menu" slot-scope="{ row, index }">
- <el-button
- type="text"
- icon="el-icon-unlock"
- size="small"
- @click="rowUnlock(row, index)"
- >解锁</el-button>
- </template>
- </avue-crud>
- </basic-container>
- </div>
- </template>
- <script>
- import option from "./config/mainList.json";
- import {lockList, lockRemove} from "@/api/lock/lock";
- export default {
- name: "index",
- data() {
- return {
- option: {},
- dataList: [],
- form: {},
- page: {
- pageSize: 10,
- pagerCount: 5,
- total: 0,
- },
- search: {},
- loading: false,
- moudleOption: [
- {
- label: '销售',
- value: 'xs'
- },
- {
- label: '采购',
- value: 'cg'
- },
- {
- label: '发货',
- value: 'fh'
- },
- {
- label: '收货',
- value: 'sh'
- },
- {
- label: '收费',
- value: 'sf'
- },
- {
- label: '付费',
- value: 'ff'
- },
- {
- label: '进项',
- value: 'jx'
- },
- {
- label: '销项',
- value: 'xx'
- },
- ]
- }
- },
- created() {
- this.option = option
- let i = 0;
- this.option.column.forEach(item => {
- if (item.search) i++
- })
- if (i % 3 !== 0){
- const num = 3 - Number(i % 3)
- this.option.searchMenuSpan = num * 8;
- this.option.searchMenuPosition = "right";
- }
- },
- filters: {
- moudleNameFormat(row, moudleOption) {
- let name;
- moudleOption.map((e) => {
- if (row == e.value) {
- name = e.label
- }
- });
- return name;
- },
- },
- methods: {
- searchChange(params, done) {
- this.onLoad(this.page, params);
- done();
- },
- currentChange(val) {
- this.page.currentPage = val;
- },
- sizeChange(val) {
- this.page.currentPage = 1;
- this.page.pageSize = val;
- },
- refreshChange() {
- this.dataList.forEach(item => {
- this.$refs.crud.toggleRowExpansion(item, false)
- })
- this.page.currentPage = 1;
- this.onLoad(this.page, this.search);
- },
- onLoad(page, params) {
- this.dataList.forEach(item => {
- this.$refs.crud.toggleRowExpansion(item, false)
- })
- this.loading = true;
- lockList(page.currentPage, page.pageSize, params)
- .then(res => {
- this.dataList = res.data.data.records ? res.data.data.records : [];
- this.page.total = res.data.data.total;
- if (this.page.total) {
- this.option.height = window.innerHeight - 260;
- }
- this.dataList.forEach(item => {
- this.$set(item,'insideList',[])
- this.$set(item,'loading', true)
- })
- })
- .finally(() => {
- this.loading = false;
- });
- },
- // 解锁
- rowUnlock(row, index) {
- this.$confirm('是否确认解锁?', '提示', {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- }).then(() => {
- return lockRemove({ids: row.id})
- }).then(() => {
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- this.page.currentPage = 1;
- this.onLoad(this.page, {parentId: 0});
- })
- },
- },
- }
- </script>
- <style scoped>
- </style>
|