list.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. <template>
  2. <div class="instock_order">
  3. <Toptitle title="领料出库单">
  4. <slot name="titleButton">
  5. <!-- <Button @click="handleCodeRule"
  6. type="primary"
  7. ghost
  8. style="margin-right:10px;">编码规则</Button> -->
  9. <!-- <Button type="primary"
  10. @click="handleGoPage(1,'')"
  11. style="margin-right:10px;">新增</Button> -->
  12. </slot>
  13. </Toptitle>
  14. <div class="instock_order_content">
  15. <div class="instock_order_search">
  16. <Form :label-width="110" :model="searchData">
  17. <FormItem label="领料出库单号:">
  18. <Input
  19. type="text"
  20. size="small"
  21. v-model="searchData.order_out_no"
  22. clearable
  23. style="width: 150px"
  24. placeholder="请输入领料出库单号"
  25. />
  26. </FormItem>
  27. <FormItem label="项目名称:">
  28. <Tooltip :content="supplierTitle" placement="top" transfer>
  29. <Select
  30. size="small"
  31. v-model="searchData.project_title"
  32. style="width: 150px"
  33. placeholder="请选择"
  34. filterable
  35. clearable
  36. @on-change="supplyChange"
  37. >
  38. <Option
  39. v-for="(item, index) in suppliersList"
  40. :key="index"
  41. :value="item"
  42. :label="item"
  43. />
  44. </Select>
  45. </Tooltip>
  46. </FormItem>
  47. <FormItem label="仓库:">
  48. <Select
  49. v-model="searchData.warehouse_id"
  50. size="small"
  51. clearable
  52. style="width: 150px"
  53. >
  54. <Option
  55. v-for="sitem in warehouseList"
  56. :key="sitem.id"
  57. :label="sitem.title"
  58. :value="sitem.id"
  59. >
  60. </Option>
  61. </Select>
  62. </FormItem>
  63. <FormItem label="出库类型:">
  64. <Select v-model="searchData.type" filterable clearable size="small">
  65. <Option
  66. v-for="sitem in purchaseTypeList"
  67. :key="sitem.id"
  68. :label="sitem.title"
  69. :value="sitem.id"
  70. >
  71. </Option>
  72. </Select>
  73. </FormItem>
  74. <FormItem label="制单人:">
  75. <Select
  76. v-model="searchData.crt_id"
  77. size="small"
  78. filterable
  79. clearable
  80. style="width: 150px"
  81. >
  82. <Option
  83. v-for="sitem in userList"
  84. :key="sitem.id"
  85. :label="sitem.nickname"
  86. :value="sitem.id"
  87. >
  88. </Option>
  89. </Select>
  90. </FormItem>
  91. <FormItem label="审批状态:">
  92. <Select
  93. v-model="searchData.state"
  94. size="small"
  95. clearable
  96. style="width: 150px"
  97. >
  98. <Option label="未审批" :value="0" />
  99. <Option label="已审批" :value="1" />
  100. </Select>
  101. </FormItem>
  102. <FormItem label="审批人:">
  103. <Select
  104. v-model="searchData.check_id"
  105. size="small"
  106. filterable
  107. clearable
  108. style="width: 150px"
  109. >
  110. <Option
  111. v-for="sitem in userList"
  112. :key="sitem.id"
  113. :label="sitem.nickname"
  114. :value="sitem.id"
  115. >
  116. </Option>
  117. </Select>
  118. </FormItem>
  119. <FormItem label="单据日期:" style="width: 430px">
  120. <DatePicker
  121. type="date"
  122. size="small"
  123. style="width: 150px"
  124. placeholder="年/月/日"
  125. v-model="searchData.start_time"
  126. ></DatePicker>
  127. ~
  128. <DatePicker
  129. type="date"
  130. size="small"
  131. style="width: 150px"
  132. placeholder="年/月/日"
  133. v-model="searchData.end_time"
  134. ></DatePicker>
  135. </FormItem>
  136. <FormItem label="订单创建时间:" style="width: 430px">
  137. <DatePicker
  138. type="date"
  139. size="small"
  140. style="width: 150px"
  141. placeholder="年/月/日"
  142. v-model="searchData.order_start_time"
  143. ></DatePicker>
  144. ~
  145. <DatePicker
  146. type="date"
  147. size="small"
  148. style="width: 150px"
  149. placeholder="年/月/日"
  150. v-model="searchData.order_end_time"
  151. ></DatePicker>
  152. </FormItem>
  153. <FormItem>
  154. <Button
  155. type="primary"
  156. size="small"
  157. @click="searchClick(searchData)"
  158. style="margin-right: 10px"
  159. >搜索</Button
  160. >
  161. </FormItem>
  162. </Form>
  163. </div>
  164. <div class="addBtn">
  165. <Button
  166. type="primary"
  167. @click="handleGoPage(1, '')"
  168. style="margin-right: 10px"
  169. size="small"
  170. >新增</Button
  171. >
  172. </div>
  173. <div class="instock_order_content_table">
  174. <Table
  175. :columns="tableColumns"
  176. border
  177. :max-height="500"
  178. :data="tableData"
  179. >
  180. <template slot="setSlot" slot-scope="{ row, index }">
  181. <!-- <a style="margin: 0 5px" @click="handleSet(6, row, index)">复制</a> -->
  182. <a style="margin: 0 5px" @click="handleSet(2, row, index)">详情</a>
  183. <a
  184. style="margin: 0 5px"
  185. v-show="row.state == 0"
  186. @click="handleSet(3, row, index)"
  187. >编辑</a
  188. >
  189. <a
  190. style="margin: 0 5px"
  191. v-show="row.state == 0"
  192. @click="handleSet(4, row, index)"
  193. >删除</a
  194. >
  195. <a style="margin: 0 5px" @click="handleSet(5, row, index)">{{
  196. row.state == 1 ? "弃审" : "审批"
  197. }}</a>
  198. </template>
  199. </Table>
  200. </div>
  201. </div>
  202. <div class="instock_order_content_page">
  203. <Page
  204. :page-size-opts="[10, 20, 30, 40, 100]"
  205. @on-page-size-change="changeSize"
  206. @on-change="changePage"
  207. :current="pageIndex"
  208. show-total
  209. :total="total"
  210. show-sizer
  211. :page-size="pageSize"
  212. />
  213. </div>
  214. </div>
  215. </template>
  216. <script>
  217. import colorSettingVue from "../../BasicSettings/colorSetting.vue";
  218. // 这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  219. // 例如:import 《组件名称》 from '《组件路径》';
  220. export default {
  221. name: "",
  222. components: {},
  223. props: {},
  224. // import引入的组件需要注入到对象中才能使用
  225. data() {
  226. // 这里存放数据
  227. return {
  228. supplierTitle: "",
  229. suppliersList: [],
  230. warehouseList: [],
  231. purchaseTypeList: [],
  232. searchData: {
  233. order_out_no: "",
  234. type: "",
  235. warehouse_id: "",
  236. crt_id: "",
  237. state: "",
  238. check_id: "",
  239. start_time: "",
  240. end_time: "",
  241. order_start_time: "",
  242. order_end_time: "",
  243. },
  244. tableColumns: [
  245. {
  246. title: "领料出库单号",
  247. key: "order_out_no",
  248. align: "center",
  249. minWidth: 140,
  250. },
  251. {
  252. title: "项目名称",
  253. key: "project_title",
  254. align: "center",
  255. minWidth: 140,
  256. },
  257. {
  258. title: "出库类型",
  259. key: "type",
  260. align: "center",
  261. minWidth: 120,
  262. render: (h, params) => {
  263. const { row } = params;
  264. return h("span", {}, row.type_title);
  265. },
  266. },
  267. {
  268. title: "仓库",
  269. key: "warehouse_title",
  270. align: "center",
  271. minWidth: 120,
  272. },
  273. { title: "制单人", key: "user_name", align: "center", minWidth: 100 },
  274. {
  275. title: "审批状态",
  276. key: "state",
  277. align: "center",
  278. minWidth: 140,
  279. render: (h, params) => {
  280. const { row } = params;
  281. const text = row.state == 0 ? "未审批" : "已审批";
  282. return h("span", {}, text);
  283. },
  284. },
  285. { title: "审批人", key: "check_name", align: "center", minWidth: 100 },
  286. {
  287. title: "单据日期",
  288. key: "order_time",
  289. align: "center",
  290. minWidth: 140,
  291. render: (h, params) => {
  292. const { row } = params;
  293. return h("span", {}, this.func.replaceDateNoHMS(row.order_time));
  294. },
  295. },
  296. {
  297. title: "订单创建时间",
  298. key: "crt_time",
  299. align: "center",
  300. minWidth: 140,
  301. render: (h, params) => {
  302. const { row } = params;
  303. return h("span", {}, this.func.replaceDate(row.crt_time));
  304. },
  305. },
  306. {
  307. title: "操作",
  308. key: "code",
  309. align: "center",
  310. minWidth: 200,
  311. slot: "setSlot",
  312. },
  313. ],
  314. tableData: [{}],
  315. pageIndex: localStorage.getItem("pageIndex") * 1 || 1,
  316. pageSize: 10,
  317. total: 0,
  318. userList: [],
  319. newSearchData:{}
  320. };
  321. },
  322. // 生命周期 - 创建完成(可以访问当前this实例)
  323. created() {
  324. //获取出库类型
  325. this.axios({
  326. method: "get",
  327. url: "/api/basic_purchase_list",
  328. params: { type_id: 3 },
  329. })
  330. .then((res) => {
  331. this.purchaseTypeList = res.data.data;
  332. })
  333. .catch((err) => {});
  334. // 获取操作员
  335. this.axios("/api/user").then((res) => (this.userList = res.data.data));
  336. // 获取仓库列表
  337. this.axios({ method: "get", url: "/api/warehouse" })
  338. .then((res) => {
  339. this.warehouseList = res.data.filter((v) => {
  340. return v.type_id == 1;
  341. });
  342. })
  343. .catch((err) => {});
  344. // 获取供应商列表
  345. this.axios({ method: "get", url: "/api/purchase_orders_list" })
  346. .then((res) => {
  347. this.suppliersList = res.data.project_name;
  348. })
  349. .catch((err) => {});
  350. },
  351. // 生命周期 - 挂载完成(可以访问DOM元素)
  352. mounted() {
  353. if (localStorage.getItem("searchData")) {
  354. this.searchData = JSON.parse(localStorage.getItem("searchData"));
  355. }
  356. if (localStorage.getItem("newSearchData")) {
  357. this.newSearchData = JSON.parse(localStorage.getItem("newSearchData"));
  358. }
  359. this.initData(this.newSearchData);
  360. },
  361. methods: {
  362. searchClick(row) {
  363. localStorage.setItem("newSearchData", JSON.stringify(row));
  364. this.newSearchData = row;
  365. this.initData(row);
  366. },
  367. supplyChange(e) {
  368. this.supplierTitle = e;
  369. },
  370. initData(row) {
  371. if (row) {
  372. var obj = JSON.parse(JSON.stringify(this.searchData));
  373. typeof this.searchData.start_time == "object"
  374. ? (obj.start_time = Date.parse(obj.start_time)
  375. .toString()
  376. .slice(0, 10))
  377. : "";
  378. typeof this.searchData.end_time == "object"
  379. ? (obj.end_time = Date.parse(obj.end_time).toString().slice(0, 10))
  380. : "";
  381. typeof this.searchData.order_start_time == "object"
  382. ? (obj.order_start_time = Date.parse(obj.order_start_time)
  383. .toString()
  384. .slice(0, 10))
  385. : "";
  386. typeof this.searchData.order_end_time == "object"
  387. ? (obj.order_end_time = Date.parse(obj.order_end_time)
  388. .toString()
  389. .slice(0, 10))
  390. : "";
  391. } else {
  392. var obj = {};
  393. }
  394. this.axios({
  395. method: "get",
  396. url: "/api/warehouse_order_out_list",
  397. params: {
  398. ...obj,
  399. page_index: this.pageIndex,
  400. page_size: this.pageSize,
  401. },
  402. })
  403. .then((res) => {
  404. this.tableData = res.data.data;
  405. this.total = res.data.total;
  406. // console.log(res)
  407. })
  408. .catch((err) => {});
  409. },
  410. handleSet(type, row, index) {
  411. // 1新增 2详情 3编辑 4删除 5审批
  412. switch (type) {
  413. case 1:
  414. case 3:
  415. this.handleGoPage(type, row.order_out_no, row.is_refer);
  416. break;
  417. case 2:
  418. this.handleGoPage(type, row.order_out_no, row.is_refer);
  419. break;
  420. case 4:
  421. this.$Modal.confirm({
  422. title: "确认删除?",
  423. content: "此操作无法恢复,请确认!",
  424. onOk: () => {
  425. this.axios({
  426. method: "get",
  427. url: "/api/warehouse_order_out_del",
  428. params: {
  429. order_out_no: row.order_out_no,
  430. },
  431. })
  432. .then((res) => {
  433. if (res.code == 200) {
  434. this.$Message.success(res.msg);
  435. this.initData();
  436. }
  437. })
  438. .catch((err) => {});
  439. },
  440. onCancel: () => {},
  441. });
  442. break;
  443. case 5:
  444. this.$Modal.confirm({
  445. title: row.state == 1 ? "确认弃审?" : "确认审批?",
  446. onOk: () => {
  447. this.axios({
  448. method: "get",
  449. url: "/api/warehouse_order_out_check",
  450. params: {
  451. order_out_no: row.order_out_no,
  452. state: row.state == 1 ? 0 : 1,
  453. },
  454. })
  455. .then((res) => {
  456. // this.$Message.success(res.msg)
  457. if (res.code == 200) {
  458. this.initData();
  459. }
  460. })
  461. .catch((err) => {});
  462. },
  463. onCancel: () => {},
  464. });
  465. break;
  466. }
  467. },
  468. handleGoPage(type, order_out_no, is_refer) {
  469. if (type == 1 || type == 3) {
  470. this.$router.push({
  471. path: "/cms/PurchasingManage/OutstockOrder/edit",
  472. query: {
  473. type,
  474. order_out_no,
  475. is_refer,
  476. },
  477. });
  478. } else {
  479. this.$router.push({
  480. path: "/cms/PurchasingManage/OutstockOrder/detail",
  481. query: {
  482. order_out_no,
  483. },
  484. });
  485. }
  486. },
  487. changeSize(e) {
  488. this.pageSize = e;
  489. this.initData();
  490. },
  491. changePage(e) {
  492. this.pageIndex = e;
  493. this.initData(this.newSearchData);
  494. },
  495. },
  496. // 监听属性 类似于data概念
  497. computed: {},
  498. // 监控data中的数据变化
  499. watch: {},
  500. // beforeRouteLeave(to, from, next) {
  501. // if (
  502. // to.path == "/cms/PurchasingManage/OutstockOrder/detail" ||
  503. // to.path == "/cms/PurchasingManage/OutstockOrder/edit"
  504. // ) {
  505. // next();
  506. // } else {
  507. // from.meta.keepAlive = false;
  508. // next();
  509. // }
  510. // },
  511. beforeRouteLeave(to, from, next) {
  512. if (to.path == "/cms/PurchasingManage/OutstockOrder/detail") {
  513. localStorage.setItem("searchData", JSON.stringify(this.searchData));
  514. localStorage.setItem("pageIndex", this.pageIndex);
  515. next();
  516. } else if (to.path == "/cms/PurchasingManage/OutstockOrder/edit") {
  517. localStorage.setItem("searchData", JSON.stringify(this.searchData));
  518. if (to.query.type == 3) {
  519. localStorage.setItem("pageIndex", this.pageIndex);
  520. localStorage.setItem("searchData", JSON.stringify(this.searchData));
  521. } else {
  522. let form = this.newSearchData;
  523. Object.keys(form).forEach((key) => (form[key] = ""));
  524. localStorage.setItem("searchData", form);
  525. localStorage.setItem("newSearchData", form);
  526. localStorage.setItem("pageIndex", 1);
  527. localStorage.removeItem("searchData");
  528. localStorage.removeItem("pageIndex");
  529. localStorage.removeItem("newSearchData");
  530. }
  531. next();
  532. } else {
  533. localStorage.removeItem("searchData");
  534. localStorage.removeItem("pageIndex");
  535. next();
  536. }
  537. },
  538. beforeCreate() {}, // 生命周期 - 创建之前
  539. beforeMount() {}, // 生命周期 - 挂载之前
  540. beforeUpdate() {}, // 生命周期 - 更新之前
  541. updated() {}, // 生命周期 - 更新之后
  542. beforeDestroy() {}, // 生命周期 - 销毁之前
  543. destroyed() {}, // 生命周期 - 销毁完成
  544. activated() {}, // 如果页面有keep-alive缓存功能,这个函数会触发
  545. };
  546. </script>
  547. <style lang='scss' scoped>
  548. .addBtn {
  549. display: flex;
  550. flex-direction: row-reverse;
  551. }
  552. .instock_order {
  553. height: 100%;
  554. }
  555. .instock_order_search {
  556. padding-top: 20px;
  557. /deep/.ivu-form {
  558. display: flex;
  559. justify-content: flex-start;
  560. flex-wrap: wrap;
  561. }
  562. /deep/.ivu-form-item {
  563. display: inline-block;
  564. width: 250px;
  565. }
  566. }
  567. .instock_order_content {
  568. height: 85%;
  569. overflow: auto;
  570. .instock_order_content_btn {
  571. display: flex;
  572. justify-content: flex-end;
  573. }
  574. }
  575. .instock_order_content_page {
  576. display: flex;
  577. justify-content: center;
  578. padding-top: 20px;
  579. }
  580. .instock_order_content_table {
  581. margin-top: 10px;
  582. }
  583. </style>