teamDetailedList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <template>
  2. <div class="">
  3. <!-- m-container -->
  4. <!-- <h2>
  5. <el-page-header @back="onCancel"
  6. content="发放清单"></el-page-header>
  7. </h2> -->
  8. <!-- <div class="headWrap">
  9. <div class="left">
  10. <div class="headItem">
  11. <p>乐团名称:<span>12345</span></p>
  12. </div>
  13. <div class="headItem">
  14. <p>生成时间:<span>12345</span></p>
  15. </div>
  16. <div class="headItem">
  17. <p>确认人:<span>12345</span></p>
  18. </div>
  19. </div>
  20. <div class="right">
  21. </div>
  22. </div> -->
  23. <div class="m-core">
  24. <div class="tableWrap">
  25. <el-table
  26. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  27. :data="tableList"
  28. >
  29. <el-table-column label="商品编号" prop="sn" align="center">
  30. </el-table-column>
  31. <el-table-column label="商品名称" align="center" prop="name">
  32. </el-table-column>
  33. <el-table-column label="商品类型" align="center" prop="type">
  34. <template slot-scope="scope">
  35. <div>
  36. {{ scope.row.type | shopType }}
  37. </div>
  38. </template>
  39. </el-table-column>
  40. <el-table-column label="具体型号" align="center" prop="specification">
  41. </el-table-column>
  42. <el-table-column label="数量统计" align="center" prop="sellCount">
  43. </el-table-column>
  44. </el-table>
  45. </div>
  46. </div>
  47. <div class="btnWrap" style="margin-top: 20px">
  48. <el-button
  49. type="primary"
  50. v-if="tableList.length > 0"
  51. v-permission="'order/musicalListExport'"
  52. @click="musicalListExport"
  53. >订货清单导出</el-button
  54. >
  55. <el-button
  56. type="primary"
  57. v-if="tableList.length > 0"
  58. v-permission="'order/musicalListDetailExport'"
  59. @click="musicalListDetailExport"
  60. >分发清单导出</el-button
  61. >
  62. <el-button
  63. type="primary"
  64. @click="onDelivery"
  65. v-if="musicalStatus && $helpers.permission('musicGroup/takeEffectOfinstrumentInsurance')"
  66. >确认发货</el-button>
  67. <el-button
  68. type="warning okBtn"
  69. v-if="team_status == 'PREPARE'&&!hasVerifyMusicalList"
  70. v-permission="'order/verifyMusicalList'"
  71. @click="okDetailList"
  72. >乐器清单确认</el-button
  73. >
  74. <!-- <div class="okBtn" v-permission="'order/verifyMusicalList'"
  75. @click="okDetailList">确认</div> -->
  76. </div>
  77. </div>
  78. </template>
  79. <script>
  80. import { getTeamDetailList, getTeamBaseInfo } from "@/api/buildTeam";
  81. import { getTeamList } from "@/api/teamServer";
  82. import { verifyMusicalList, takeEffectOfinstrumentInsurance } from "@/api/orderManager";
  83. import axios from "axios";
  84. import qs from "qs";
  85. import { getToken, getTenantId } from "@/utils/auth";
  86. import load from "@/utils/loading";
  87. export default {
  88. data() {
  89. return {
  90. teamid: "",
  91. tableList: [],
  92. Fsearch: null,
  93. Frules: null,
  94. team_status: "",
  95. musicalInstrumentsProvideStatus: 0, // 是否确认发货 1已发货
  96. hasVerifyMusicalList:true
  97. };
  98. },
  99. mounted() {
  100. this.init();
  101. },
  102. activated() {
  103. this.init();
  104. },
  105. computed: {
  106. musicalStatus() {
  107. const template = ['PREPARE', 'PROGRESS']
  108. const teamStatus = this.$route.query.team_status
  109. const status = template.includes(teamStatus)
  110. console.log(this.musicalInstrumentsProvideStatus, status)
  111. return !this.musicalInstrumentsProvideStatus && status ? true : false
  112. }
  113. },
  114. methods: {
  115. init() {
  116. this.team_status = this.$route.query.team_status;
  117. this.teamid = this.$route.query.id;
  118. if (this.teamid) {
  119. getTeamList({ musicGroupId: this.teamid }).then(res=>{
  120. if(res.code == 200){
  121. this.hasVerifyMusicalList = res?.data?.rows[0]?.hasVerifyMusicalList
  122. }
  123. })
  124. getTeamDetailList({ musicGroupId: this.teamid }).then((res) => {
  125. if (res.code == 200) {
  126. this.tableList = res.data ? res.data : [];
  127. }
  128. });
  129. this.getMusicInfo()
  130. }
  131. },
  132. async getMusicInfo() {
  133. await getTeamBaseInfo({ musicGroupId: this.teamid }).then((res) => {
  134. if (res.code == 200) {
  135. this.musicalInstrumentsProvideStatus = res.data?.musicGroup?.musicalInstrumentsProvideStatus
  136. }
  137. });
  138. },
  139. onCancel() {
  140. this.$store.dispatch("delVisitedViews", this.$route);
  141. this.$router.push({ path: "/teamList" });
  142. },
  143. onDelivery() {
  144. this.$confirm('是否确认发货', "提示", {
  145. confirmButtonText: "确定",
  146. cancelButtonText: "取消",
  147. type: "warning",
  148. }).then(async () => {
  149. try {
  150. await takeEffectOfinstrumentInsurance({ musicGroupId: this.teamid })
  151. this.$message.success('确定发货成功')
  152. this.getMusicInfo()
  153. } catch {
  154. //
  155. }
  156. })
  157. },
  158. okDetailList() {
  159. this.$confirm(`是否确认发放清单?`, "提示", {
  160. confirmButtonText: "确定",
  161. cancelButtonText: "取消",
  162. type: "warning",
  163. })
  164. .then(() => {
  165. verifyMusicalList({ musicGroupId: this.teamid }).then((res) => {
  166. if (res.code == 200) {
  167. this.$store.dispatch("delVisitedViews", this.$route);
  168. this.$router.push({
  169. path: "/teamList",
  170. query: { search: this.Fsearch, rules: this.Frules },
  171. });
  172. }
  173. });
  174. })
  175. .catch(() => {});
  176. },
  177. musicalListExport() {
  178. // 报表导出
  179. let url = "/api-web/order/musicalListExport";
  180. let data = {
  181. musicGroupId: this.$route.query.id,
  182. };
  183. const options = {
  184. method: "POST",
  185. headers: {
  186. Authorization: getToken(),
  187. tenantId: getTenantId()
  188. },
  189. data: qs.stringify(data),
  190. url,
  191. responseType: "blob",
  192. };
  193. this.$confirm("您确定导出订货清单", "提示", {
  194. confirmButtonText: "确定",
  195. cancelButtonText: "取消",
  196. type: "warning",
  197. })
  198. .then(() => {
  199. load.startLoading();
  200. axios(options)
  201. .then((res) => {
  202. let blob = new Blob([res.data], {
  203. // type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
  204. type: "application/vnd.ms-excel;charset=utf-8",
  205. //word文档为application/msword,pdf文档为application/pdf,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8
  206. });
  207. let text = new Response(blob).text();
  208. text.then((res) => {
  209. // 判断是否报错
  210. if (res.indexOf("code") != -1) {
  211. let json = JSON.parse(res);
  212. if(json.code == 403) {
  213. this.$message.error(`登录过期,请重新登录!`)
  214. setTimeout(() => {
  215. this.$store.dispatch('user/resetToken').then(() => {
  216. location.reload()
  217. })
  218. }, 1000);
  219. return
  220. }
  221. this.$message.error(json.msg);
  222. } else {
  223. let objectUrl = URL.createObjectURL(blob);
  224. let link = document.createElement("a");
  225. let nowTime = new Date();
  226. let ymd =
  227. nowTime.getFullYear() +
  228. "" +
  229. (nowTime.getMonth() + 1) +
  230. "" +
  231. nowTime.getDate() +
  232. "" +
  233. nowTime.getHours() +
  234. "" +
  235. nowTime.getMinutes();
  236. let fname = this.$route.query.id + "-" + ymd + "订货清单.xls"; //下载文件的名字
  237. link.href = objectUrl;
  238. link.setAttribute("download", fname);
  239. document.body.appendChild(link);
  240. link.click();
  241. }
  242. });
  243. load.endLoading();
  244. })
  245. .catch((error) => {
  246. this.$message.error("导出数据失败,请联系管理员");
  247. load.endLoading();
  248. });
  249. })
  250. .catch(() => {});
  251. },
  252. musicalListDetailExport() {
  253. // 报表导出
  254. let url = "/api-web/order/musicalListDetailExport";
  255. let data = {
  256. musicGroupId: this.$route.query.id,
  257. };
  258. const options = {
  259. method: "POST",
  260. headers: {
  261. Authorization: getToken(),
  262. tenantId: getTenantId()
  263. },
  264. data: qs.stringify(data),
  265. url,
  266. responseType: "blob",
  267. };
  268. this.$confirm("您确定导出分发清单", "提示", {
  269. confirmButtonText: "确定",
  270. cancelButtonText: "取消",
  271. type: "warning",
  272. })
  273. .then(() => {
  274. load.startLoading();
  275. axios(options)
  276. .then((res) => {
  277. let blob = new Blob([res.data], {
  278. // type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
  279. type: "application/vnd.ms-excel;charset=utf-8",
  280. //word文档为application/msword,pdf文档为application/pdf,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8
  281. });
  282. let text = new Response(blob).text();
  283. text.then((res) => {
  284. // 判断是否报错
  285. if (res.indexOf("code") != -1) {
  286. let json = JSON.parse(res);
  287. if(json.code == 403) {
  288. this.$message.error(`登录过期,请重新登录!`)
  289. setTimeout(() => {
  290. this.$store.dispatch('user/resetToken').then(() => {
  291. location.reload()
  292. })
  293. }, 1000);
  294. return
  295. }
  296. this.$message.error(json.msg);
  297. } else {
  298. let objectUrl = URL.createObjectURL(blob);
  299. let link = document.createElement("a");
  300. let nowTime = new Date();
  301. let ymd =
  302. nowTime.getFullYear() +
  303. "" +
  304. (nowTime.getMonth() + 1) +
  305. "" +
  306. nowTime.getDate() +
  307. "" +
  308. nowTime.getHours() +
  309. "" +
  310. nowTime.getMinutes();
  311. let fname = this.$route.query.id + "-" + ymd + "分发清单.xls"; //下载文件的名字
  312. link.href = objectUrl;
  313. link.setAttribute("download", fname);
  314. document.body.appendChild(link);
  315. link.click();
  316. }
  317. });
  318. load.endLoading();
  319. })
  320. .catch((error) => {
  321. this.$message.error("导出数据失败,请联系管理员");
  322. load.endLoading();
  323. });
  324. })
  325. .catch(() => {});
  326. },
  327. },
  328. };
  329. </script>
  330. <style lang="scss">
  331. </style>