stock_log.js 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: () => {
  4. const { reactive, onMounted } = Vue
  5. const index = {
  6. setup() {
  7. const state = reactive({
  8. data: [],
  9. order: '',
  10. sort: '',
  11. filter: {
  12. drawer: false,
  13. data: {
  14. 'goods.title': '',
  15. },
  16. tools: {
  17. 'goods.title': {
  18. type: 'tinput',
  19. label: '商品名称',
  20. placeholder: '请输入商品名称',
  21. value: '',
  22. },
  23. },
  24. condition: {},
  25. }
  26. })
  27. function getData() {
  28. let tempSearch = JSON.parse(JSON.stringify(state.filter.data));
  29. let search = composeFilter(tempSearch, {
  30. 'goods.title': 'like',
  31. });
  32. Fast.api.ajax({
  33. url: 'shopro/goods/stock_log',
  34. type: 'GET',
  35. data: {
  36. page: pagination.page,
  37. list_rows: pagination.list_rows,
  38. order: state.order,
  39. sort: state.sort,
  40. ...search,
  41. },
  42. }, function (ret, res) {
  43. state.data = res.data.data
  44. pagination.total = res.data.total
  45. return false
  46. }, function (ret, res) { })
  47. }
  48. function onChangeSort({ prop, order }) {
  49. state.order = order == 'ascending' ? 'asc' : 'desc';
  50. state.sort = prop;
  51. getData();
  52. }
  53. function onOpenFilter() {
  54. state.filter.drawer = true
  55. }
  56. function onChangeFilter() {
  57. pagination.page = 1
  58. getData()
  59. state.filter.drawer && (state.filter.drawer = false)
  60. }
  61. const pagination = reactive({
  62. page: 1,
  63. list_rows: 10,
  64. total: 0,
  65. })
  66. onMounted(() => {
  67. getData()
  68. })
  69. return {
  70. state,
  71. getData,
  72. onChangeSort,
  73. onOpenFilter,
  74. onChangeFilter,
  75. pagination,
  76. }
  77. }
  78. }
  79. createApp('index', index);
  80. },
  81. };
  82. return Controller;
  83. });