index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. <template>
  2. <!-- 营销-积分商品 -->
  3. <div>
  4. <Card :bordered="false" dis-hover class="ivu-mt" :padding="0">
  5. <div class="new_card_pd">
  6. <!-- 查询条件 -->
  7. <Form ref="tableFrom" inline :model="tableFrom" :label-width="labelWidth"
  8. :label-position="labelPosition" @submit.native.prevent>
  9. <!-- <FormItem label="创建时间:" label-for="user_time">
  10. <DatePicker
  11. :editable="false"
  12. @on-change="onchangeTime"
  13. :value="timeVal"
  14. format="yyyy/MM/dd"
  15. type="datetimerange"
  16. placement="bottom-start"
  17. placeholder="自定义时间"
  18. class="mr20 input-add"
  19. :options="options"
  20. ></DatePicker>
  21. </FormItem> -->
  22. <!-- <FormItem label="上架状态:">
  23. <Select
  24. placeholder="请选择"
  25. clearable
  26. class="input-add"
  27. v-model="tableFrom.is_show"
  28. >
  29. <Option value="1">上架</Option>
  30. <Option value="0">下架</Option>
  31. </Select>
  32. </FormItem> -->
  33. <FormItem label="仓位搜索:" label-for="store_name">
  34. <Input class="input-add mr14" placeholder="请输入仓位名称" v-model="tableFrom.key" />
  35. <Button type="primary" @click="tableSearchs()">查询</Button>
  36. </FormItem>
  37. <!-- <Button
  38. v-auth="['marketing-store_seckill-create']"
  39. type="primary"
  40. icon="md-add"
  41. @click="addMore"
  42. class="mr10"
  43. >批量添加积分商品</Button
  44. > -->
  45. <!--<Button v-auth="['export-storeSeckill']" class="export" icon="ios-share-outline" @click="exports">导出</Button>-->
  46. </Form>
  47. </div>
  48. </Card>
  49. <Card :bordered="false" dis-hover class="ivu-mt">
  50. <!-- 操作 -->
  51. <Button v-auth="['admin-erp-add_position']" type="primary" @click="add" class="mr10">添加商品</Button>
  52. <!-- 积分商品-表格 -->
  53. <Table :columns="columns1" :data="tableList" :loading="loading" highlight-row no-userFrom-text="暂无数据"
  54. no-filtered-userFrom-text="暂无筛选结果" class="ivu-mt">
  55. <template slot-scope="{ row, index }" slot="passageway">
  56. <span> {{ row.bin_number.slice(0,2) }}</span>
  57. </template>
  58. <template slot-scope="{ row, index }" slot="control">
  59. <span> {{ row.bin_number.slice(2,3) }}</span>
  60. </template>
  61. <template slot-scope="{ row, index }" slot="layer">
  62. <span> {{ row.bin_number.slice(3,4) }}</span>
  63. </template>
  64. <template slot-scope="{ row, index }" slot="number">
  65. <span> {{ row.bin_number.slice(4) }}</span>
  66. </template>
  67. <template slot-scope="{ row, index }" slot="unit_name_1">
  68. <div v-if="row.unit_name_1">
  69. <div>名称:{{row.unit_name_1}}</div>
  70. <div>转换率:1{{row.unit_name_1}} = {{row.unit_rate_1*1}}{{row.unit_name}}</div>
  71. </div>
  72. </template>
  73. <template slot-scope="{ row, index }" slot="unit_name_2">
  74. <div v-if="row.unit_name_2">
  75. <div>名称:{{row.unit_name_2}}</div>
  76. <div>转换率:1{{row.unit_name_2}} = {{row.unit_rate_2*1}}{{row.unit_name}}</div>
  77. </div>
  78. </template>
  79. <template slot-scope="{ row, index }" slot="is_weigh">
  80. {{row.is_weigh == 1?'是': '否'}}
  81. </template>
  82. <template slot-scope="{ row, index }" slot="action">
  83. <!-- <a @click="look(row)">详情</a>
  84. <Divider type="vertical" /> -->
  85. <a @click="edit(row)">编辑</a>
  86. <!-- <Divider type="vertical" />
  87. <a @click="del(row, '删除仓位', index)">删除</a> -->
  88. </template>
  89. </Table>
  90. <div class="acea-row row-right page">
  91. <Page :total="total" :current="tableFrom.page" show-elevator show-total @on-change="pageChange"
  92. :page-size="tableFrom.limit" />
  93. </div>
  94. </Card>
  95. <productDetail ref="productDetail"></productDetail>
  96. </div>
  97. </template>
  98. <script>
  99. import {
  100. mapState
  101. } from "vuex";
  102. import {
  103. integralProductListApi,
  104. integralIsShowApi,
  105. storeSeckillApi,
  106. } from "@/api/marketing";
  107. import {
  108. getGoods,
  109. getUserInfo,
  110. getGoodInfo
  111. } from "@/api/erp";
  112. import {
  113. formatDate
  114. } from "@/utils/validate";
  115. import timeOptions from "@/utils/timeOptions";
  116. import Setting from "@/setting";
  117. import productDetail from './productDetail.vue'
  118. export default {
  119. name: "godownList",
  120. components: {
  121. productDetail
  122. },
  123. filters: {
  124. formatDate(time) {
  125. if (time !== 0) {
  126. let date = new Date(time * 1000);
  127. return formatDate(date, "yyyy-MM-dd");
  128. }
  129. },
  130. },
  131. data() {
  132. return {
  133. roterPre: Setting.roterPre,
  134. loading: false,
  135. options: timeOptions,
  136. columns1: [{
  137. title: "ID",
  138. key: "id",
  139. width: 80,
  140. },
  141. {
  142. title: "商品名称",
  143. key: "store_name",
  144. minWidth: 90,
  145. },
  146. {
  147. title: "总销量",
  148. key: "all_sales",
  149. minWidth: 90,
  150. },
  151. {
  152. title: "总库存",
  153. key: "stock",
  154. minWidth: 90,
  155. },
  156. {
  157. title: "基础单位",
  158. key: "unit_name",
  159. minWidth: 90,
  160. },
  161. {
  162. title: "大单位",
  163. slot: "unit_name_1",
  164. minWidth: 90,
  165. },
  166. {
  167. title: "超大单位",
  168. slot: "unit_name_2",
  169. minWidth: 90,
  170. },
  171. {
  172. title: "商品条码",
  173. key: "bar_code",
  174. minWidth: 90,
  175. },
  176. {
  177. title: "成本价",
  178. key: "cost",
  179. minWidth: 90,
  180. },
  181. {
  182. title: "是否称重",
  183. slot: "is_weigh",
  184. minWidth: 90,
  185. },
  186. {
  187. title: "操作",
  188. slot: "action",
  189. fixed: "right",
  190. width: 200,
  191. },
  192. ],
  193. tableList: [],
  194. timeVal: [],
  195. grid: {
  196. xl: 7,
  197. lg: 10,
  198. md: 12,
  199. sm: 24,
  200. xs: 24,
  201. },
  202. tableFrom: {
  203. // integral_time: "",
  204. // is_show: "",
  205. // store_name: "",
  206. key: '',
  207. page: 1,
  208. limit: 10,
  209. },
  210. total: 0,
  211. };
  212. },
  213. computed: {
  214. ...mapState("admin/layout", ["isMobile"]),
  215. labelWidth() {
  216. return this.isMobile ? undefined : 96;
  217. },
  218. labelPosition() {
  219. return this.isMobile ? "top" : "right";
  220. },
  221. },
  222. created() {
  223. this.getList();
  224. },
  225. methods: {
  226. look(row) {
  227. try{
  228. this.$refs.productDetail.getInfo(row.id)
  229. }catch(e){
  230. //TODO handle the exception
  231. }
  232. // getGoodInfo(row.id).then(res=> {
  233. // console.log(res,'商品详情');
  234. // })
  235. },
  236. // 添加
  237. add() {
  238. this.$router.push({
  239. path: this.roterPre + "/erp/product_add?id=0"
  240. });
  241. },
  242. addMore() {
  243. this.$router.push({
  244. path: this.roterPre + "/marketing/store_integral/add_store_integral",
  245. });
  246. },
  247. orderList(row) {
  248. this.$router.push({
  249. path: this.roterPre + "/marketing/store_integral/order_list",
  250. query: {
  251. product_id: row.id,
  252. },
  253. });
  254. },
  255. // 导出
  256. exports() {
  257. let formValidate = this.tableFrom;
  258. let data = {
  259. start_status: formValidate.start_status,
  260. status: formValidate.status,
  261. store_name: formValidate.store_name,
  262. };
  263. storeSeckillApi(data)
  264. .then((res) => {
  265. location.href = res.data[0];
  266. })
  267. .catch((res) => {
  268. this.$Message.error(res.msg);
  269. });
  270. },
  271. // 编辑
  272. edit(row) {
  273. this.$router.push({
  274. path: this.roterPre + "/erp/product_add?id=" + row.id
  275. });
  276. },
  277. // 一键复制
  278. copy(row) {
  279. this.$router.push({
  280. path: this.roterPre + "/marketing/store_integral/create/" + row.id + "/1",
  281. });
  282. },
  283. // 删除
  284. del(row, tit, num) {
  285. let delfromData = {
  286. title: tit,
  287. num: num,
  288. url: `/erp/Warehouse/position_del/${row.id}`,
  289. method: "DELETE",
  290. ids: "",
  291. };
  292. this.$modalSure(delfromData)
  293. .then((res) => {
  294. this.$Message.success(res.msg);
  295. this.tableList.splice(num, 1);
  296. if (!this.tableList.length) {
  297. this.tableFrom.page =
  298. this.tableFrom.page == 1 ? 1 : this.tableFrom.page - 1;
  299. }
  300. this.getList();
  301. })
  302. .catch((res) => {
  303. this.$Message.error(res.msg);
  304. });
  305. },
  306. // 列表
  307. getList() {
  308. this.loading = true;
  309. // this.tableFrom.start_status = this.tableFrom.start_status || "";
  310. // this.tableFrom.is_show = this.tableFrom.is_show || "";
  311. getGoods(this.tableFrom)
  312. .then(async (res) => {
  313. let data = res.data;
  314. this.tableList = data.data;
  315. this.total = data.count;
  316. this.loading = false;
  317. })
  318. .catch((res) => {
  319. this.loading = false;
  320. this.$Message.error(res.msg);
  321. });
  322. },
  323. pageChange(index) {
  324. this.tableFrom.page = index;
  325. this.getList();
  326. },
  327. // 表格搜索
  328. tableSearchs() {
  329. this.tableFrom.page = 1;
  330. this.getList();
  331. },
  332. // 具体日期
  333. onchangeTime(e) {
  334. this.timeVal = e;
  335. this.tableFrom.integral_time = this.timeVal[0] ? this.timeVal.join("-") : "";
  336. },
  337. // 修改是否显示
  338. onchangeIsShow(row) {
  339. let data = {
  340. id: row.id,
  341. is_show: row.is_show,
  342. };
  343. integralIsShowApi(data)
  344. .then(async (res) => {
  345. this.$Message.success(res.msg);
  346. })
  347. .catch((res) => {
  348. this.$Message.error(res.msg);
  349. });
  350. },
  351. },
  352. };
  353. </script>
  354. <style scoped lang="stylus">
  355. .tabBox_img {
  356. width: 36px;
  357. height: 36px;
  358. border-radius: 4px;
  359. cursor: pointer;
  360. img {
  361. width: 100%;
  362. height: 100%;
  363. }
  364. }
  365. </style>