家政小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.vue 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <style lang="less">
  2. @import '../../styles/common.less';
  3. .ivu-card-head {
  4. p {
  5. height: 32px;
  6. line-height: 32px;
  7. }
  8. button {
  9. float: right;
  10. }
  11. }
  12. </style>
  13. <template>
  14. <div>
  15. <Row class="margin-top-10" v-show="proShow">
  16. <Col>
  17. <Card>
  18. <p slot="title">
  19. <Icon type="android-remove"></Icon>
  20. 保姆订单
  21. <Button type="primary" @click="add">新增</Button>
  22. </p>
  23. <div class="edittable-table-height-con">
  24. <Table :columns="columns" :data="prosHandle"></Table>
  25. <Page :total="total" :page-size="pageSize" @on-change="getData"></Page>
  26. </div>
  27. </Card>
  28. </Col>
  29. </Row>
  30. <edit v-show="editShow" @pub-success="pubSuccess" :form-content="formContent"></edit>
  31. </div>
  32. </template>
  33. <script>
  34. import edit from "./edit";
  35. export default {
  36. name: 'product',
  37. components: {
  38. edit
  39. },
  40. computed: {
  41. editShow() {
  42. return !this.proShow;
  43. },
  44. prosHandle() {
  45. let products = [].concat(JSON.parse(JSON.stringify(this.products)));
  46. for (let product of products) {
  47. if (product.status == 0) {
  48. product.status = "待处理";
  49. } else if (product.status == 1) {
  50. product.status = "商家受理";
  51. } else if (product.status == 2) {
  52. product.status = "待支付";
  53. } else {
  54. product.status = "已支付";
  55. }
  56. }
  57. return products;
  58. }
  59. },
  60. data () {
  61. return {
  62. total: 0,
  63. pageSize: 20,
  64. proShow: true,
  65. formContent: {},
  66. columns: [
  67. {title: "id", key: 'id'},
  68. {title: "项目", key: 'contents'},
  69. {title: "人数", key: 'people_num'},
  70. {title: "服务时间", key: 'server_time'},
  71. {title: "休息时间", key: 'rest'},
  72. {title: "房屋面积", key: 'area'},
  73. {title: "服务地址", key: 'address'},
  74. {title: "联系人", key: 'contact', align: 'center'},
  75. {title: "联系电话", key: 'phone', align: 'center'},
  76. {title: "订单价格", key: 'price', align: 'center'},
  77. {title: "订单状态", key: 'status', align: 'center'},
  78. {
  79. title: "操作",
  80. key: "action",
  81. align: 'center',
  82. render: (h, params) => {
  83. return h('div', [
  84. h('Button', {
  85. props: {
  86. type: 'primary',
  87. size: 'default'
  88. },
  89. style: {
  90. marginRight: '5px'
  91. },
  92. on: {
  93. click: () => {
  94. let id = params.row.id;
  95. this.proShow = false;
  96. this.products.forEach((product) => {
  97. if (product.id == id) {
  98. this.formContent = product;
  99. }
  100. })
  101. }
  102. }
  103. }, '修改'),
  104. h('Button', {
  105. props: {
  106. type: 'error',
  107. size: 'default'
  108. },
  109. style: {
  110. marginRight: '5px'
  111. },
  112. on: {
  113. click: () => {
  114. let id = params.row.id;
  115. this.axios.delete(`/housekeeper_order/${id}`)
  116. .then((res) => {
  117. this.products = this.products.filter((product) => {
  118. if (product.id != id) {
  119. return true;
  120. }
  121. });
  122. });
  123. }
  124. }
  125. }, '删除')
  126. ]);
  127. }
  128. }
  129. ],
  130. products: []
  131. };
  132. },
  133. methods: {
  134. add () {
  135. this.proShow = false;
  136. this.formContent = {};
  137. },
  138. pubSuccess() {
  139. this.proShow = true;
  140. this.getData();
  141. },
  142. getData (num) {
  143. this.axios.get("/housekeeper_orders", {
  144. params: {
  145. page: num || 1
  146. }
  147. }).then((res) => {
  148. this.products = res.data.data;
  149. this.pageSize = res.data.per_page;
  150. this.total = res.data.total;
  151. });
  152. }
  153. },
  154. created () {
  155. this.getData();
  156. }
  157. };
  158. </script>