index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  1. <template>
  2. <div class="survey pagePadding">
  3. <div
  4. v-if="powers && powers.length > 0 && powers.some((item) => item == '001')"
  5. >
  6. <ex-table
  7. v-loading="false"
  8. :table="table"
  9. :data="tableData"
  10. :columns="columns"
  11. :page="pageInfo"
  12. :size="size"
  13. @page-curr-change="handlePageChange"
  14. @page-size-change="handleSizeChange"
  15. @screen-reset="
  16. pageInfo.curr = 1;
  17. parmValue.page = 1;
  18. searchList();
  19. "
  20. @screen-submit="
  21. pageInfo.curr = 1;
  22. parmValue.page = 1;
  23. searchList();
  24. "
  25. >
  26. <template #table-header="{}">
  27. <div style="width: 100%" class="min">
  28. <el-row style="padding: 0 0 0 80px">
  29. <el-col :span="24">
  30. <!-- 请选择仓库 -->
  31. <el-col :span="5" style="width: 250px">
  32. <el-cascader
  33. placeholder="请选择仓库"
  34. filterable
  35. clearable
  36. :size="searchSize"
  37. v-model="value"
  38. :options="options"
  39. style="width: 100%"
  40. @change="
  41. pageInfo.curr = 1;
  42. parmValue.page = 1;
  43. searchList();
  44. "
  45. ></el-cascader>
  46. </el-col>
  47. <!-- 商品编码 -->
  48. <el-col :span="4" style="width: 160px; padding: 0 0 0 10px">
  49. <el-input
  50. style="width: 100%"
  51. :size="searchSize"
  52. v-model="parmValue.name"
  53. :maxlength="40"
  54. placeholder="商品编码"
  55. />
  56. </el-col>
  57. <!-- 库存量 -->
  58. <el-col :span="6" style="width: 273px; padding: 0 0 0 10px">
  59. <number-range
  60. :start="parmValue.total_low"
  61. :end="parmValue.total_up"
  62. :type="1"
  63. :width="'120px'"
  64. :title="'库存量'"
  65. :size="searchSize"
  66. @numReturned="numReturned($event, 0)"
  67. />
  68. </el-col>
  69. <!-- 预警库存量 -->
  70. <el-col :span="6" style="width: 303px" class="mr8">
  71. <number-range
  72. :start="parmValue.total_low"
  73. :end="parmValue.total_up"
  74. :type="1"
  75. :width="'135px'"
  76. :title="'预警量'"
  77. :size="searchSize"
  78. @numReturned="numReturned($event, 0)"
  79. />
  80. </el-col>
  81. <!-- 搜索 -->
  82. <el-col :span="4" style="width: 74px" class="mr10">
  83. <el-button
  84. :size="searchSize"
  85. type="primary"
  86. class="fr"
  87. icon="el-icon-search"
  88. label=""
  89. @click="searchList"
  90. >搜索</el-button
  91. >
  92. </el-col>
  93. <!-- 重置 -->
  94. <el-col
  95. :span="4"
  96. style="width: 74px; margin-left: 10px"
  97. class="mr5"
  98. >
  99. <el-button
  100. :size="searchSize"
  101. class="fr"
  102. icon="el-icon-refresh-right"
  103. @click="searchList"
  104. >重置</el-button
  105. >
  106. </el-col>
  107. <!-- <el-col
  108. :span="4"
  109. style="width: 66px"
  110. >
  111. <el-button
  112. type="warning"
  113. class="fr"
  114. :size="searchSize"
  115. @click="restSearch"
  116. >
  117. 重置
  118. </el-button>
  119. </el-col>
  120. <el-col
  121. :span="3"
  122. style="width: 66px; float: right"
  123. >
  124. <el-button
  125. :size="searchSize"
  126. type="primary"
  127. style="float: right; margin-left: 5px"
  128. @click="searchList"
  129. >
  130. 刷新
  131. </el-button>
  132. </el-col> -->
  133. </el-col>
  134. </el-row>
  135. </div>
  136. </template>
  137. <!-- <template #status="{ scope }">
  138. <el-tag
  139. :size="tablebtnSize"
  140. :type="scope.row.status == '0' ? 'warning' : ''"
  141. v-text="
  142. (statusOptions.find((item) => item.id == scope.row.status) || {})
  143. .label || '--'
  144. "
  145. ></el-tag>
  146. </template> -->
  147. <!-- <template #operation="{ scope }">
  148. <div>123{{ scope.row }}</div>
  149. <el-tooltip
  150. v-if="powers.some((item) => item == '005')"
  151. effect="dark"
  152. content="修改"
  153. placement="top"
  154. >
  155. <i
  156. class="el-icon-edit tb-icon"
  157. @click="openModal(scope.row, false, scope.row)"
  158. ></i>
  159. </el-tooltip>
  160. <el-tooltip
  161. v-if="
  162. powers.some((item) => item == '004') && scope.row.status === '1'
  163. "
  164. effect="dark"
  165. content="禁用"
  166. placement="top"
  167. >
  168. <i
  169. class="el-icon-video-pause tb-icon"
  170. @click="statusConfirm(scope.row.id, scope.row.status)"
  171. ></i>
  172. </el-tooltip>
  173. <el-tooltip
  174. v-if="
  175. powers.some((item) => item == '004') && scope.row.status === '0'
  176. "
  177. effect="dark"
  178. content="启用"
  179. placement="top"
  180. >
  181. <i
  182. class="el-icon-video-play tb-icon"
  183. @click="statusConfirm(scope.row.id, scope.row.status)"
  184. ></i>
  185. </el-tooltip>
  186. </template> -->
  187. </ex-table>
  188. <add-edit
  189. :id="modelId"
  190. :sitem="sitem"
  191. :show-model="showModel"
  192. :is-detail="isDetail"
  193. @refresh="searchList"
  194. @cancel="showModel = false"
  195. />
  196. </div>
  197. <div v-else>
  198. <no-auth></no-auth>
  199. </div>
  200. <add-edit
  201. :showModel="showModel"
  202. :row="row"
  203. :isDetail="isDetail"
  204. @refresh="searchList"
  205. @cancel="showModel = false"
  206. ></add-edit>
  207. </div>
  208. </template>
  209. <script>
  210. import mixinPage from "@/mixins/elPaginationHandle";
  211. import resToken from "@/mixins/resToken";
  212. import ExTable from "@/components/ExTableNew.vue";
  213. import statusList from "@/assets/js/statusList";
  214. // import asyncRequest from "@/apis/service/stock/survey";
  215. import asyncRequest from "@/mock/service/stock/stockWarning";
  216. import addEdit from "./addEdit";
  217. import { mapGetters } from "vuex";
  218. import numberRange from "@/components/numberRange";
  219. export default {
  220. name: "survey",
  221. mixins: [mixinPage, resToken],
  222. components: {
  223. addEdit,
  224. ExTable,
  225. numberRange,
  226. },
  227. computed: {
  228. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  229. powers() {
  230. let tran =
  231. this.$store.getters.btnList.find(
  232. (item) => item.menu_route == "stockWarning"
  233. ) || {};
  234. if (tran && tran.action && tran.action.length > 0) {
  235. return tran.action;
  236. } else {
  237. return [];
  238. }
  239. },
  240. },
  241. data() {
  242. return {
  243. options: [],
  244. // stock: [
  245. // { id: "1", name: "自建仓" },
  246. // { id: "2", name: "自建仓" },
  247. // { id: "1", name: "部门仓" },
  248. // { id: "2", name: "部门仓" },
  249. // ],
  250. // sitem: null,
  251. statusList: statusList,
  252. loading: true,
  253. showModel: false,
  254. isDetail: false,
  255. modelId: 0,
  256. row: "",
  257. parmValue: {
  258. stock_sn: "", // 商品编码
  259. stock_start: 0, //库存量开始
  260. stock_end: 0, //库存量结束
  261. stockWarn_start: 0, //预警量开始
  262. stockWarn_end: 0, //预警量结束
  263. status: "", //
  264. page: 1, // 页码
  265. size: 15, // 每页显示条数
  266. },
  267. tableData: [],
  268. // 表格 - 数据
  269. tableData: [],
  270. // 表格 - 参数
  271. table: {
  272. stripe: true,
  273. border: true,
  274. _defaultHeader_: ["setcol"],
  275. },
  276. // 表格 - 分页
  277. pageInfo: {
  278. size: 15,
  279. curr: 1,
  280. total: 0,
  281. },
  282. // 表格 - 列参数
  283. columns: [
  284. {
  285. prop: "orderNo",
  286. label: "商品编码",
  287. },
  288. {
  289. prop: "goods",
  290. label: "商品名称",
  291. },
  292. {
  293. prop: "attribute",
  294. label: "属性名称",
  295. },
  296. {
  297. prop: "type",
  298. label: "分类",
  299. },
  300. {
  301. prop: "unit",
  302. label: "单位",
  303. },
  304. {
  305. prop: "number",
  306. label: "可用库存",
  307. },
  308. {
  309. prop: "warnNumber",
  310. label: "预警库存",
  311. },
  312. {
  313. prop: "",
  314. label: "操作",
  315. fixed: "right",
  316. _noset_: true,
  317. _slot_: "operation",
  318. },
  319. ],
  320. // 状态
  321. // statusOptions: [
  322. // { id: "0", label: "禁用" },
  323. // { id: "1", label: "启用" },
  324. // ],
  325. // passwordModel: false,
  326. // passwordModelId: 0,
  327. // isPasswordDetail: false,
  328. };
  329. },
  330. mounted() {
  331. this.searchList();
  332. this.stockName();
  333. },
  334. methods: {
  335. restSearch() {
  336. this.parmValue = {
  337. // name: "", // 业务员名字
  338. // username: "", // 账号
  339. // status: "", //
  340. // page: 1, // 页码
  341. // size: 10, // 每页显示条数
  342. };
  343. this.searchList();
  344. },
  345. openModal(id, isDetail, sitem) {
  346. console.log(id);
  347. console.log(isDetail);
  348. this.showModel = true;
  349. this.row = id;
  350. this.isDetail = isDetail;
  351. this.sitem = sitem;
  352. },
  353. async deleteById(id, status) {
  354. // await this.$confirm("确定要删除?", {
  355. // confirmButtonText: "确定",
  356. // cancelButtonText: "取消",
  357. // type: "warning",
  358. // })
  359. // .then(async () => {
  360. // const model = {
  361. // id: id,
  362. // status: status === "1" ? "0" : "1",
  363. // };
  364. // const res = await asyncRequest.status(model);
  365. // if (res && res.code === 0) {
  366. // this.$notify.success({
  367. // title: "删除成功",
  368. // message: "",
  369. // });
  370. // this.searchList();
  371. // } else if (res && res.code >= 100 && res.code <= 104) {
  372. // await this.logout();
  373. // } else {
  374. // this.$message.warning(res.message);
  375. // }
  376. // })
  377. // .catch(() => {
  378. // console.log("取消");
  379. // });
  380. },
  381. async searchList() {
  382. this.loading = true;
  383. const res = await asyncRequest.list(this.parmValue);
  384. if (res && res.code === 0 && res.data) {
  385. // console.log(res.data.list);
  386. this.tableData = res.data.list;
  387. this.pageInfo.total = Number(res.data.count);
  388. } else if (res && res.code >= 100 && res.code <= 104) {
  389. await this.logout();
  390. } else {
  391. this.tableData = [];
  392. this.pageInfo.total = 0;
  393. }
  394. this.loading = false;
  395. },
  396. async statusConfirm(id, status) {
  397. // let str = status === "1" ? "禁用" : "启用";
  398. // await this.$confirm("确定要改为" + str + "?", {
  399. // confirmButtonText: "确定",
  400. // cancelButtonText: "取消",
  401. // type: "warning",
  402. // })
  403. // .then(async () => {
  404. // this.loading = true;
  405. // const model = {
  406. // id: id,
  407. // status: status === "1" ? "0" : "1",
  408. // };
  409. // const res = await asyncRequest.status(model);
  410. // if (res && res.code === 0) {
  411. // this.loading = false;
  412. // this.$notify.success({
  413. // title: "状态修改成功!",
  414. // message: "",
  415. // });
  416. // await this.searchList();
  417. // } else if (res && res.code >= 100 && res.code <= 104) {
  418. // await this.logout();
  419. // } else {
  420. // this.$message.warning(res.message);
  421. // }
  422. // })
  423. // .catch(() => {
  424. // console.log("取消");
  425. // });
  426. },
  427. async stockName() {
  428. //获取多级仓库名称的方法
  429. const res = await asyncRequest.listAll(this.parmValue);
  430. // console.log(res.data);
  431. // this.options = res.data;
  432. // console.log(this.options);
  433. let arr = res.data;
  434. // console.log(arr);
  435. arr.forEach((ele) => {
  436. let item = {
  437. value: ele.id,
  438. label: ele.name,
  439. children: [],
  440. };
  441. ele.child.forEach((elem) => {
  442. let model = {
  443. value: elem.id,
  444. label: elem.name,
  445. };
  446. item.children.push(model);
  447. });
  448. this.options.push(item);
  449. });
  450. // console.log(this.options);
  451. // console.log(this.pageInfo.total);
  452. },
  453. },
  454. };
  455. </script>
  456. <style lang="scss" scoped>
  457. .mr10 {
  458. margin-left: 10px;
  459. }
  460. @media screen and (max-width: 1473px) {
  461. .mr5 {
  462. // margin-left: 0px !important;
  463. margin-top: 10px;
  464. }
  465. }
  466. @media screen and (max-width: 1389px) {
  467. .mr10 {
  468. margin-top: 10px;
  469. }
  470. }
  471. .mr8 {
  472. padding: 0 0 0 10px;
  473. }
  474. @media screen and (max-width: 1305px) {
  475. .mr8 {
  476. margin-top: 10px;
  477. padding-left: 0;
  478. }
  479. .mr10 {
  480. margin-left: 0px;
  481. }
  482. }
  483. .to {
  484. float: left;
  485. height: 32px;
  486. line-height: 32px;
  487. padding-left: 6px;
  488. }
  489. .min {
  490. min-width: 1050px;
  491. }
  492. /**
  493. import numberRange from "@/components/numberRange";
  494. */
  495. </style>