index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <div class="standBook pagePadding">
  3. <div
  4. v-loading="loading"
  5. v-if="powers && powers.length > 0 && powers.some((item) => item == '001')"
  6. >
  7. <el-row style="padding: 10px 0 0 0">
  8. <el-col :span="4" style="width: 200px; padding: 0 10px 0 0" class="fl">
  9. <el-select
  10. v-model="value"
  11. :size="searchSize"
  12. placeholder="请选择类型"
  13. style="width: 100%"
  14. >
  15. <el-option
  16. v-for="item in options"
  17. :key="item.value"
  18. :label="item.label"
  19. :value="item.value"
  20. >
  21. </el-option>
  22. </el-select>
  23. </el-col>
  24. <el-col :span="6" style="width: 292px">
  25. <period-date-picker
  26. :start="parmValue.start"
  27. :end="parmValue.end"
  28. :type="2"
  29. :width="'135px'"
  30. :size="searchSize"
  31. @timeReturned="timeReturned($event)"
  32. />
  33. </el-col>
  34. <el-col
  35. :span="4"
  36. style="width: 83px"
  37. class="fr"
  38. v-if="powers.some((item) => item == '049')"
  39. >
  40. <el-button
  41. type="primary"
  42. class="fr"
  43. icon="el-icon-download"
  44. :size="searchSize"
  45. @click="batchExport(selection)"
  46. >导出</el-button
  47. >
  48. </el-col>
  49. <el-col
  50. :span="4"
  51. class="fr"
  52. style="width: 66px; margin: 0 0 0 10px"
  53. v-if="powers.some((item) => item == '024')"
  54. >
  55. <el-button
  56. type="warning"
  57. class="fr"
  58. :size="searchSize"
  59. @click="restSearch"
  60. >
  61. 重置
  62. </el-button>
  63. </el-col>
  64. </el-row>
  65. </div>
  66. <no-auth v-else></no-auth>
  67. </div>
  68. </template>
  69. <script>
  70. import resToken from "@/mixins/resToken";
  71. import urlConfig from "@/apis/url-config";
  72. import PeriodDatePicker from "@/components/PeriodDatePicker";
  73. import { mapGetters } from "vuex";
  74. export default {
  75. name: "standBook",
  76. mixins: [resToken],
  77. components: {
  78. PeriodDatePicker,
  79. },
  80. computed: {
  81. //组件SIZE设置
  82. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  83. //组件SIZE设置
  84. powers() {
  85. let tran =
  86. this.$store.getters.btnList.find(
  87. (item) => item.menu_route == "standBook"
  88. ) || {};
  89. if (tran && tran.action && tran.action.length > 0) {
  90. return tran.action;
  91. } else {
  92. return [];
  93. }
  94. },
  95. },
  96. data() {
  97. return {
  98. options: [
  99. {
  100. value: "1",
  101. label: "确认单台账",
  102. },
  103. {
  104. value: "2",
  105. label: "确认单明细",
  106. },
  107. {
  108. value: "3",
  109. label: "采购单台账",
  110. },
  111. {
  112. value: "4",
  113. label: "采购单明细",
  114. },
  115. {
  116. value: "5",
  117. label: "退货台账",
  118. },
  119. ],
  120. value: "1",
  121. loading: false,
  122. fileUrl: urlConfig.baseURL + "Admin/",
  123. parmValue: {
  124. start:"",
  125. end:"",
  126. },
  127. // 表格 - 数据
  128. tableData: [],
  129. };
  130. },
  131. mounted() {},
  132. methods: {
  133. restSearch() {
  134. // console.log("123456789");
  135. this.value = "1";
  136. this.parmValue = {
  137. starttime: "",
  138. endtime: "",
  139. };
  140. },
  141. async timeReturned(e) {
  142. if (e.startTime !== "") {
  143. this.parmValue.start = e.startTime;
  144. } else {
  145. this.parmValue.start = "";
  146. }
  147. if (e.endTime !== "") {
  148. this.parmValue.end = e.endTime;
  149. } else {
  150. this.parmValue.end = "";
  151. }
  152. },
  153. /**
  154. * 批量导出开票信息
  155. * * @param {Array} selection //选中的对账编码
  156. */
  157. async batchExport() {
  158. if (!this.loading) {
  159. if (this.parmValue.start === "" || this.parmValue.end === "") {
  160. this.$message.warning("请选择时间区间!");
  161. return;
  162. }
  163. this.loading = true;
  164. let url = "";
  165. if (this.value === "1") {
  166. url = "downreportqrdtz";
  167. } else if (this.value === "2") {
  168. url = "downreportqrd";
  169. } else if (this.value === "3") {
  170. url = "downreportcgdtz";
  171. } else if (this.value === "4") {
  172. url = "downreportcgd";
  173. } else {
  174. url = "downreportthtz";
  175. }
  176. this.loading = true;
  177. let httpType = `aplication/zip`;
  178. axios({
  179. method: "post",
  180. url: urlConfig.baseURL + url,
  181. responseType: "blob",
  182. data: this.parmValue,
  183. headers: {
  184. Accept: httpType,
  185. },
  186. })
  187. .then((res) => {
  188. if (res && res.status == 200 && res.data) {
  189. let title =
  190. (this.options.find((item) => item.value == this.value) || {})
  191. .label || "--";
  192. let blob = new Blob([res.data], {
  193. type: httpType,
  194. });
  195. let url = window.URL.createObjectURL(blob);
  196. let aLink = document.createElement("a");
  197. aLink.style.display = "none";
  198. aLink.href = url;
  199. aLink.setAttribute(
  200. "download",
  201. `${this.parmValue.start}至${this.parmValue.end}${title}.zip`
  202. );
  203. document.body.appendChild(aLink);
  204. aLink.click();
  205. document.body.removeChild(aLink); //下载完成移除元素
  206. window.URL.revokeObjectURL(url); //释放掉blob对象
  207. this.$message.success(title + `信息导出成功!`);
  208. setTimeout(() => {
  209. this.loading = false;
  210. }, 500);
  211. } else {
  212. this.$message.error(res.data.message);
  213. setTimeout(() => {
  214. this.loading = false;
  215. }, 500);
  216. }
  217. })
  218. .catch((error) => {
  219. this.loading = false;
  220. });
  221. }
  222. },
  223. },
  224. };
  225. </script>
  226. <style lang="scss" scoped>
  227. </style>