1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: () => {
- const { reactive, onMounted } = Vue
- const index = {
- setup() {
- const state = reactive({
- data: [],
- order: '',
- sort: '',
- filter: {
- drawer: false,
- data: {
- 'goods.title': '',
- },
- tools: {
- 'goods.title': {
- type: 'tinput',
- label: '商品名称',
- placeholder: '请输入商品名称',
- value: '',
- },
- },
- condition: {},
- }
- })
- function getData() {
- let tempSearch = JSON.parse(JSON.stringify(state.filter.data));
- let search = composeFilter(tempSearch, {
- 'goods.title': 'like',
- });
- Fast.api.ajax({
- url: 'shopro/goods/stock_log',
- type: 'GET',
- data: {
- page: pagination.page,
- list_rows: pagination.list_rows,
- order: state.order,
- sort: state.sort,
- ...search,
- },
- }, function (ret, res) {
- state.data = res.data.data
- pagination.total = res.data.total
- return false
- }, function (ret, res) { })
- }
- function onChangeSort({ prop, order }) {
- state.order = order == 'ascending' ? 'asc' : 'desc';
- state.sort = prop;
- getData();
- }
- function onOpenFilter() {
- state.filter.drawer = true
- }
- function onChangeFilter() {
- pagination.page = 1
- getData()
- state.filter.drawer && (state.filter.drawer = false)
- }
- const pagination = reactive({
- page: 1,
- list_rows: 10,
- total: 0,
- })
- onMounted(() => {
- getData()
- })
- return {
- state,
- getData,
- onChangeSort,
- onOpenFilter,
- onChangeFilter,
- pagination,
- }
- }
- }
- createApp('index', index);
- },
- };
- return Controller;
- });
|