index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. <template>
  2. <div class="stockWarning pagePadding">
  3. <div
  4. v-if="powers && powers.length > 0 && powers.some((item) => item == '001')"
  5. >
  6. <div style="width: 100%">
  7. <el-row style="padding: 20px 0 0 30px">
  8. <el-col :span="8">
  9. <CompanySearch
  10. style="dispaly: inline-block; padding-left: 10px"
  11. @searchCard="getCompany"
  12. :isSize="isSize"
  13. ></CompanySearch>
  14. </el-col>
  15. <el-col :span="8"
  16. ><StockSearch
  17. :isDisabled="isDesabled"
  18. :isSize="isSize"
  19. ></StockSearch
  20. ></el-col>
  21. </el-row>
  22. </div>
  23. <div class="stock-survey clear">
  24. <el-row v-for="item in stock_list" :key="item.id" style="float: left">
  25. <el-col :span="24" class="card">
  26. <el-card shadow="always">
  27. <i :class="item.icon" class="icon"></i>
  28. <!-- <p>{{ item.num }}</p> -->
  29. <countTo
  30. style="display: block"
  31. :startVal="startVal"
  32. :endVal="item.endVal"
  33. :duration="3000"
  34. ></countTo>
  35. <p style="margin-top: 5px">{{ item.label }}</p>
  36. </el-card>
  37. </el-col>
  38. </el-row>
  39. </div>
  40. <ex-table
  41. v-loading="false"
  42. :table="table"
  43. :data="tableData"
  44. :columns="columns"
  45. :page="pageInfo"
  46. :size="size"
  47. @row-click="handClick"
  48. @page-curr-change="handlePageChange"
  49. @page-size-change="handleSizeChange"
  50. @screen-reset="
  51. pageInfo.curr = 1;
  52. parmValue.page = 1;
  53. searchList();
  54. "
  55. @screen-submit="
  56. pageInfo.curr = 1;
  57. parmValue.page = 1;
  58. searchList();
  59. "
  60. >
  61. <template #table-header="{}">
  62. <div style="width: 100%; height: 30px; line-height: 30px">
  63. <i class="el-icon-s-unfold" style="height: 10px"></i>库存操作记录
  64. </div>
  65. </template>
  66. </ex-table>
  67. <add-edit
  68. :id="modelId"
  69. :sitem="sitem"
  70. :show-model="showModel"
  71. :is-detail="isDetail"
  72. @refresh="searchList"
  73. @cancel="showModel = false"
  74. />
  75. </div>
  76. <div v-else>
  77. <no-auth></no-auth>
  78. </div>
  79. </div>
  80. </template>
  81. <script>
  82. import mixinPage from "@/mixins/elPaginationHandle";
  83. import resToken from "@/mixins/resToken";
  84. // import statusList from "@/assets/js/statusList";
  85. // import asyncRequest from "@/apis/service/stock/stockWarning";
  86. import asyncRequest from "@/mock/service/stock/survey";
  87. import countTo from "vue-count-to";
  88. import addEdit from "./addEdit";
  89. import { mapGetters } from "vuex";
  90. export default {
  91. name: "survey",
  92. mixins: [mixinPage, resToken],
  93. components: {
  94. addEdit,
  95. countTo,
  96. },
  97. computed: {
  98. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  99. powers() {
  100. let tran =
  101. this.$store.getters.btnList.find(
  102. (item) => item.menu_route == "survey"
  103. ) || {};
  104. if (tran && tran.action && tran.action.length > 0) {
  105. return tran.action;
  106. } else {
  107. return [];
  108. }
  109. },
  110. },
  111. data() {
  112. return {
  113. isSize: true, //控制输入框的尺寸
  114. isDesabled: "",
  115. options: [], //用于渲染多级仓库的数据
  116. startVal: 0, //动态效果显示卡片内的数字数量
  117. stock: [],
  118. stock_list: [
  119. //渲染表格上方的卡片选项用的
  120. {
  121. id: "1",
  122. icon: "el-icon-box",
  123. label: "当前库存",
  124. num: 0,
  125. endVal: 0,
  126. },
  127. {
  128. id: "2",
  129. icon: "el-icon-download",
  130. label: "待入库",
  131. endVal: 0,
  132. num: 0,
  133. },
  134. {
  135. id: "3",
  136. icon: "el-icon-upload2",
  137. label: "待出库",
  138. endVal: 0,
  139. num: 0,
  140. },
  141. {
  142. id: "4",
  143. icon: "el-icon-shopping-cart-full",
  144. label: "可用库存",
  145. endVal: 0,
  146. num: 0,
  147. },
  148. {
  149. id: "5",
  150. icon: "el-icon-truck",
  151. label: "在途库存",
  152. num: 0,
  153. endVal: 0,
  154. },
  155. ],
  156. arr1: [],
  157. loading: true,
  158. showModel: false,
  159. isDetail: false,
  160. modelId: 0,
  161. tableData: [], // 表格 - 数据
  162. table: {
  163. // 表格 - 参数
  164. stripe: true,
  165. border: true,
  166. // _defaultHeader_: ["setcol"],
  167. },
  168. // 表格 - 分页
  169. pageInfo: {
  170. size: 15,
  171. curr: 1,
  172. total: 0,
  173. },
  174. columns: [
  175. // 表格 - 列参数
  176. {
  177. prop: "id",
  178. label: "记录编号",
  179. },
  180. {
  181. prop: "author",
  182. label: "操作人",
  183. },
  184. {
  185. prop: "reviewer",
  186. label: "部门",
  187. },
  188. {
  189. prop: "type",
  190. label: "库存类型",
  191. },
  192. {
  193. prop: "number",
  194. label: "操作数量",
  195. // _slot_: "status",
  196. // width: "80px",
  197. },
  198. {
  199. prop: "typeo",
  200. label: "库存来源",
  201. // sortable: true,
  202. },
  203. {
  204. prop: "addTime",
  205. label: "操作时间",
  206. // sortable: true,
  207. },
  208. ],
  209. parmValue: {
  210. //入参参数
  211. // name: "", // 业务员名字
  212. // username: "", // 账号
  213. // status: "", //
  214. // page: 1, // 页码
  215. // size: 15, // 每页显示条数
  216. },
  217. // 状态
  218. // statusOptions: [
  219. // { id: "0", label: "禁用" },
  220. // { id: "1", label: "启用" },
  221. // ],
  222. // nowStock: 20, //当前库存
  223. // stayStock: 0, //待入库
  224. // stayOutStock: 0, //待出库
  225. // stockAble: 0, //可用库存
  226. // roadStock: 10, //在途库存
  227. // sitem: null,
  228. // tableData: [], //渲染表格数据
  229. // passwordModel: false,
  230. // passwordModelId: 0,
  231. // isPasswordDetail: false,
  232. // statistics: [],
  233. };
  234. },
  235. mounted() {
  236. this.searchList(); //获取表格信息
  237. // this.stockList(); //获取卡片内库存数据信息
  238. // this.stockName(); //获取多级仓库列表信息
  239. },
  240. methods: {
  241. wchange(e) {
  242. console.log(e);
  243. },
  244. restSearch() {
  245. //清空入参参数
  246. // this.parmValue = {
  247. // name: "", // 业务员名字
  248. // username: "", // 账号
  249. // status: "", //
  250. // page: 1, // 页码
  251. // size: 10, // 每页显示条数
  252. // };
  253. // this.searchList();
  254. // // this.stock_list[0].num
  255. },
  256. openModal(id, isDetail, sitem) {
  257. //打开弹窗
  258. this.showModel = true;
  259. this.modelId = id;
  260. this.isDetail = isDetail;
  261. this.sitem = sitem;
  262. },
  263. async deleteById(id, status) {
  264. //删除功能
  265. // await this.$confirm("确定要删除?", {
  266. // confirmButtonText: "确定",
  267. // cancelButtonText: "取消",
  268. // type: "warning",
  269. // })
  270. // .then(async () => {
  271. // const model = {
  272. // id: id,
  273. // status: status === "1" ? "0" : "1",
  274. // };
  275. // const res = await asyncRequest.status(model);
  276. // if (res && res.code === 0) {
  277. // this.$notify.success({
  278. // title: "删除成功",
  279. // message: "",
  280. // });
  281. // this.searchList();
  282. // } else if (res && res.code >= 100 && res.code <= 104) {
  283. // await this.logout();
  284. // } else {
  285. // this.$message.warning(res.message);
  286. // }
  287. // })
  288. // .catch(() => {
  289. // console.log("取消");
  290. // });
  291. },
  292. getCompany(val) {
  293. console.log("获取仓库数据");
  294. console.log(val);
  295. this.isDesabled = val;
  296. console.log(this.isDesabled);
  297. this.stockList();
  298. },
  299. async stockList() {
  300. //获取表格上方的卡片数据
  301. // console.log(this.stock_list);
  302. const res1 = await asyncRequest.statistics(this.parmValue);
  303. // console.log(res1.data);
  304. const { value1, value2, value3, value4, value5 } = res1.data;
  305. this.stock.push(value1, value2, value3, value4, value5);
  306. // this.endVal = value1;
  307. // console.log(this.stock);
  308. // console.log(this.stock_list[5].num);
  309. for (let i = 0; i <= this.stock_list.length - 1; i++) {
  310. // this.stock_list[i].num = this.stock[i];
  311. this.stock_list[i].endVal = this.stock[i];
  312. }
  313. // console.log(this.stock_list);
  314. },
  315. // async stockName() {
  316. // //获取多级仓库名称的方法
  317. // const res = await asyncRequest.listAll(this.parmValue);
  318. // // console.log(res.data);
  319. // // this.options = res.data;
  320. // // console.log(this.options);
  321. // let arr = res.data;
  322. // // console.log(arr);
  323. // arr.forEach((ele) => {
  324. // let item = {
  325. // value: ele.id,
  326. // label: ele.name,
  327. // children: [],
  328. // };
  329. // ele.child.forEach((elem) => {
  330. // let model = {
  331. // value: elem.id,
  332. // label: elem.name,
  333. // };
  334. // item.children.push(model);
  335. // });
  336. // this.options.push(item);
  337. // });
  338. // console.log(this.options);
  339. // // console.log(this.pageInfo.total);
  340. // },
  341. async searchList() {
  342. //获取表格数据
  343. this.loading = true;
  344. // const res = await asyncRequest.list(this.parmValue);
  345. const res = await asyncRequest.log(this.parmValue);
  346. // console.log(res);
  347. if (res && res.code === 0 && res.data) {
  348. // this.tableData = res.data;
  349. this.tableData = res.data.list;
  350. this.pageInfo.total = Number(res.data.count);
  351. // console.log(this.tableData);
  352. // this.pageInfo.total = Number(res.data.count);
  353. } else if (res && res.code >= 100 && res.code <= 104) {
  354. await this.logout();
  355. } else {
  356. this.tableData = [];
  357. this.pageInfo.total = 0;
  358. }
  359. this.loading = false;
  360. },
  361. async statusConfirm(id, status) {
  362. //启用禁用状态
  363. // let str = status === "1" ? "禁用" : "启用";
  364. // await this.$confirm("确定要改为" + str + "?", {
  365. // confirmButtonText: "确定",
  366. // cancelButtonText: "取消",
  367. // type: "warning",
  368. // })
  369. // .then(async () => {
  370. // this.loading = true;
  371. // const model = {
  372. // id: id,
  373. // status: status === "1" ? "0" : "1",
  374. // };
  375. // const res = await asyncRequest.status(model);
  376. // if (res && res.code === 0) {
  377. // this.loading = false;
  378. // this.$notify.success({
  379. // title: "状态修改成功!",
  380. // message: "",
  381. // });
  382. // await this.searchList();
  383. // } else if (res && res.code >= 100 && res.code <= 104) {
  384. // await this.logout();
  385. // } else {
  386. // this.$message.warning(res.message);
  387. // }
  388. // })
  389. // .catch(() => {
  390. // console.log("取消");
  391. // });
  392. },
  393. },
  394. };
  395. </script>
  396. <style lang="scss" scoped>
  397. @import "~@/styles/index.scss";
  398. .card {
  399. width: 200px;
  400. height: 115px;
  401. flex: 1;
  402. }
  403. @media screen and (max-width: 1500px) {
  404. .card {
  405. width: 160px;
  406. }
  407. }
  408. @media screen and (max-width: 1350px) {
  409. .card {
  410. width: 130px;
  411. }
  412. }
  413. .stock-survey {
  414. width: 100%;
  415. display: flex;
  416. // position: relative;
  417. justify-content: space-around;
  418. overflow: hidden;
  419. padding: 20px 0 20px 10px;
  420. text-align: center;
  421. .icon {
  422. font-size: 40px;
  423. padding-bottom: 10px;
  424. }
  425. p {
  426. cursor: default;
  427. }
  428. }
  429. </style>