家政小程序
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 9.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <style lang="less">
  2. @import '../../styles/common.less';
  3. </style>
  4. <template>
  5. <div>
  6. <Row class="margin-top-10" v-show="proShow">
  7. <Col>
  8. <Card>
  9. <p slot="title">
  10. <Icon type="android-remove"></Icon>
  11. 产品订单
  12. <span class="search">
  13. <Input v-model="keyword" @on-enter="search" />
  14. <Button type="primary" @click="search">搜索</Button>
  15. </span>
  16. </p>
  17. <div class="edittable-table-height-con">
  18. <Table :columns="columns" :data="prosHandle"></Table>
  19. <Page :total="total" :page-size="pageSize" @on-change="changePage"></Page>
  20. </div>
  21. </Card>
  22. </Col>
  23. </Row>
  24. <edit :editShow="editShow" :row="row" @close="closeModal"></edit>
  25. <remark :remarkShow="remarkShow" :row="row" @close="closeRemark"></remark>
  26. <detail v-show="!proShow" :form-content="formContent" @back="back"></detail>
  27. </div>
  28. </template>
  29. <script>
  30. import edit from "./edit";
  31. import remark from "./remark";
  32. import detail from "./detail";
  33. export default {
  34. name: 'product',
  35. components: {
  36. edit,
  37. remark,
  38. detail
  39. },
  40. computed: {
  41. prosHandle() {
  42. let products = [].concat(JSON.parse(JSON.stringify(this.products)));
  43. for (let product of products) {
  44. if (product.status == 0) {
  45. product.status = "待处理";
  46. } else if (product.status == 1) {
  47. product.status = "待支付";
  48. } else if (product.status == 2) {
  49. product.status = "已支付";
  50. } else if (product.status == 3) {
  51. product.status = "关闭";
  52. } else {
  53. product.status = "支付失败";
  54. }
  55. }
  56. return products;
  57. }
  58. },
  59. data () {
  60. return {
  61. row: {},
  62. total: 0,
  63. pageSize: 20,
  64. proShow: true,
  65. editShow: false,
  66. remarkShow: false,
  67. keyword: '',
  68. formContent: {},
  69. columns: [
  70. {title: "产品列表", key: 'list', type: 'html', width: 300},
  71. // {title: "产品名称", key: 'name'},
  72. // {title: "购买数量", key: 'amount'},
  73. // {title: "买家备注", key: 'remark'},
  74. // {title: "卖家备注", key: 'info'},
  75. // {title: "服务地址", key: 'address'},
  76. {title: "联系人", key: 'contact', align: 'center'},
  77. {title: "联系电话", key: 'phone', align: 'center'},
  78. {title: "订单价格", key: 'price', align: 'center', editable: true},
  79. {title: "订单状态", key: 'status', align: 'center'},
  80. {title: "备注", key: 'info', align: 'center'},
  81. // {title: "评论", key: 'comment', align: 'center'},
  82. {
  83. title: "操作",
  84. key: "action",
  85. align: 'center',
  86. width: 300,
  87. render: (h, params) => {
  88. return h('div', [
  89. h('Button', {
  90. props: {
  91. type: 'primary',
  92. size: 'default'
  93. },
  94. style: {
  95. marginRight: '5px'
  96. },
  97. on: {
  98. click: () => {
  99. this.formContent = params.row;
  100. this.proShow = false;
  101. }
  102. }
  103. }, '详情'),
  104. h('Button', {
  105. props: {
  106. type: 'primary',
  107. size: 'default'
  108. },
  109. style: {
  110. marginRight: '5px'
  111. },
  112. on: {
  113. click: () => {
  114. this.row = params.row;
  115. this.editShow = true;
  116. }
  117. }
  118. }, '修改'),
  119. h('Button', {
  120. props: {
  121. type: 'primary',
  122. size: 'default'
  123. },
  124. style: {
  125. marginRight: '5px'
  126. },
  127. on: {
  128. click: () => {
  129. this.row = params.row;
  130. this.remarkShow = true;
  131. }
  132. }
  133. }, '备注'),
  134. h('Button', {
  135. props: {
  136. type: 'error',
  137. size: 'default'
  138. },
  139. style: {
  140. marginRight: '5px'
  141. },
  142. on: {
  143. click: () => {
  144. let id = params.row.id;
  145. this.$Modal.confirm({
  146. title: '注意',
  147. content: '确定要删除?',
  148. onOk: () => {
  149. this.axios.delete(`/product_order/${id}`)
  150. .then((res) => {
  151. this.products = this.products.filter((product) => {
  152. if (product.id != id) {
  153. return true;
  154. }
  155. });
  156. this.$Modal.remove();
  157. });
  158. },
  159. onCancel: () => {
  160. this.$Modal.remove();
  161. }
  162. });
  163. }
  164. }
  165. }, '删除')
  166. ]);
  167. }
  168. }
  169. ],
  170. products: []
  171. };
  172. },
  173. methods: {
  174. getData (num) {
  175. this.axios.get("/product_orders", {
  176. params: {
  177. page: num || 1
  178. }
  179. }).then((res) => {
  180. let products = [];
  181. res.data.data.forEach((product, i) => {
  182. let obj = JSON.parse(JSON.stringify(product));
  183. let list = [];
  184. let photo = [];
  185. product.products.forEach((pro) => {
  186. list.push(`分类:${pro.classify},产品:${pro.name},数量:${pro.pivot.product_amount}`);
  187. if (pro.photo) {
  188. photo.push(pro.photo);
  189. }
  190. });
  191. obj.list = list.join("<br>");
  192. obj.photo = photo.join(";");
  193. products.push(obj);
  194. });
  195. this.products = products;
  196. this.pageSize = res.data.per_page;
  197. this.total = res.data.total;
  198. });
  199. },
  200. closeModal(row) {
  201. this.editShow = false;
  202. if (row && row.id) {
  203. this.products.forEach((product, i) => {
  204. if (product.id == row.id) {
  205. product.price = row.price;
  206. this.$set(this.products, i, product);
  207. }
  208. });
  209. }
  210. },
  211. closeRemark(row) {
  212. this.remarkShow = false;
  213. if (row && row.id) {
  214. this.products.forEach((product, i) => {
  215. if (product.id == row.id) {
  216. product.info = row.remark;
  217. this.$set(this.products, i, product);
  218. }
  219. });
  220. }
  221. },
  222. back() {
  223. this.proShow = true;
  224. },
  225. changePage(num) {
  226. if (this.keyword) {
  227. this.search(num);
  228. } else {
  229. this.getData(num);
  230. }
  231. },
  232. search(num) {
  233. this.axios.get("/product_orders", {
  234. params: {
  235. keyword: this.keyword,
  236. page: num || 1
  237. }
  238. }).then((res) => {
  239. this.products = res.data.data;
  240. this.pageSize = res.data.per_page;
  241. this.total = res.data.total;
  242. });
  243. }
  244. },
  245. created () {
  246. this.getData();
  247. }
  248. };
  249. </script>