index.vue 12 KB

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