{"remainingRequest":"/Users/admin/projects/dms/src/dealer_admin/node_modules/vue-loader/lib/index.js??vue-loader-options!/Users/admin/projects/dms/src/dealer_admin/src/views/product/index.vue?vue&type=script&lang=js","dependencies":[{"path":"/Users/admin/projects/dms/src/dealer_admin/src/views/product/index.vue","mtime":1713161556000},{"path":"/Users/admin/projects/dms/src/dealer_admin/node_modules/cache-loader/dist/cjs.js","mtime":499162500000},{"path":"/Users/admin/projects/dms/src/dealer_admin/node_modules/babel-loader/lib/index.js","mtime":456789000000},{"path":"/Users/admin/projects/dms/src/dealer_admin/node_modules/cache-loader/dist/cjs.js","mtime":499162500000},{"path":"/Users/admin/projects/dms/src/dealer_admin/node_modules/vue-loader/lib/index.js","mtime":499162500000}],"contextDependencies":[],"result":["//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n\nimport * as API from \"@/api/product.js\";\nimport waves from \"@/directive/waves\"; \nimport Pagination from \"@/components/Pagination\";\nimport {parseTime} from \"@/utils\";\n\nexport default {\n  name: \"ProductList\",\n  components: {Pagination},\n  directives: {waves},\n  data() {\n    return {\n      list: [],\n      total: 0,\n      listLoading: false,\n      listQuery: {\n        page: 1,\n        limit: 10,\n        search: '',\n      },\n      exportLoading: false\n    };\n  },\n  created() {\n    this.init();\n  },\n  methods: {\n    async init(){\n      this.listQuery = {\n        page: 1,\n        limit: 10,\n        search: '',\n      };\n      await this.getList();\n    },\n    async getList() {\n      this.listLoading = true;\n      const res = await API.getList(this.listQuery);\n      let {total,list} = res.result;\n      this.total = total;\n      this.list = [];\n      this.list = list;\n      this.listLoading = false;\n    },\n    handle(id) {\n      this.$nextTick(() => {\n        this.$refs.handle.init(id);\n      });\n    },\n    lookDetail(id){\n      this.$nextTick(() => {\n        this.$refs.dealer.init(id);\n      });\n    },\n    handleFilter() {\n      this.listQuery.page = 1;\n      this.getList();\n    },\n    exportExcel() {\n      this.exportLoading = true;\n      import(\"@/vendor/Export2Excel\").then((excel) => {\n        const tHeader = [\n          \"产品编号\",\n          \"产品名称\",\n          \"面价\",\n          \"可用库存\",\n\n        ];\n        const filterVal = [\n          \"product_no\",\n          \"productname\",\n          \"unit_price\",\n          \"qtyearly\",\n        ];\n        const newList = this.list.map((e) => {\n          //console.log(e);\n          return {\n            ...e\n          };\n        });\n        console.log(\"newList:\", newList);\n        const data = this.formatJson(filterVal, newList);\n        console.log(\"data:\", data);\n        excel.export_json_to_excel({\n          header: tHeader,\n          data,\n          filename: \"产品列表\",\n        });\n        this.exportLoading = false;\n      });\n    },\n    formatJson(filterVal, jsonData) {\n      return jsonData.map((v) =>\n        filterVal.map((j) => {\n          return v[j];\n        })\n      );\n    },\n  }\n};\n",null]}