detail.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <!-- 出库信息审核-详情页 -->
  2. <template>
  3. <basic-container>
  4. <el-row style="min-height: 300px">
  5. <el-table :data="tableData" style="width: 100%" stripe border>
  6. <el-table-column prop="outboundType" label="出库类型" header-align="center" align="center">
  7. <template #default="scope">
  8. {{ scope.row.outboundType ? showCh(scope.row.outboundType, outdound_type) : scope.row.outboundType }}
  9. </template>
  10. </el-table-column>
  11. <el-table-column prop="materialGroup" label="物资大类" header-align="center" align="center" />
  12. <el-table-column prop="materialType" label="物资类别" header-align="center" align="center" />
  13. <el-table-column prop="materialName" label="物资名称" header-align="center" align="center" />
  14. <el-table-column prop="unit" label="单位" header-align="center" align="center" />
  15. <el-table-column prop="quantity" label="数量" header-align="center" align="center" />
  16. <el-table-column prop="province" label="调用省份" header-align="center" align="center">
  17. <template #default="scope">
  18. {{ scope.row.province ? showCh(scope.row.province, province_ch) : scope.row.province }}
  19. </template>
  20. </el-table-column>
  21. <el-table-column prop="outboundTime" label="出库日期" header-align="center" align="center" />
  22. <el-table-column prop="unitPrice" label="单价(元)" header-align="center" align="center" />
  23. <el-table-column prop="totalPrice" label="价值(万元)" header-align="center" align="center" />
  24. <el-table-column prop="isAvailable" label="是否可用" header-align="center" align="center">
  25. <template #default="scope">
  26. {{ scope.row.isAvailable ? showCh(scope.row.isAvailable, is_available) : scope.row.isAvailable }}
  27. </template>
  28. </el-table-column>
  29. <el-table-column label="附件上传" header-align="center" align="center" width="160">
  30. <template #default="scope">
  31. <span class="fileName" @click="fileDownload(scope.row.filePart, scope.row.fileName)">{{
  32. scope.row.fileName
  33. }}</span>
  34. </template>
  35. </el-table-column>
  36. <el-table-column prop="remarks" label="备注" header-align="center" align="center" />
  37. </el-table>
  38. </el-row>
  39. <div style="padding: 30px 40px 0">
  40. <!-- <el-row v-if="auditData && auditData.length > 0"> -->
  41. <el-row v-if="1">
  42. <el-table :data="auditData" style="width: 100%" stripe border>
  43. <el-table-column prop="opinion" label="审核意见" header-align="center" align="center" />
  44. <el-table-column label="附件" header-align="center" align="center">
  45. <template #default="scope">
  46. <span class="fileName" @click="fileDownload(scope.row.filePart, scope.row.fileName)">{{
  47. scope.row.fileName
  48. }}</span>
  49. </template>
  50. </el-table-column>
  51. <el-table-column prop="auditingTime" label="审核时间" header-align="center" align="center" />
  52. </el-table>
  53. </el-row>
  54. <el-form :model="formData" v-if="!isShow" label-width="100px" class="whole_form">
  55. <el-row class="audit-form" style="margin-top: 50px">
  56. <el-col :span="24">
  57. <el-form-item label="审核意见:">
  58. <el-input
  59. type="textarea"
  60. rows="4"
  61. v-model="formData.opinion"
  62. placeholder="请输入"
  63. style="width: 100%"
  64. /> </el-form-item
  65. ></el-col>
  66. <el-col :span="24">
  67. <el-form-item label="附件上传:">
  68. <el-upload
  69. v-model:file-list="formData.fileList"
  70. class="upload-demo"
  71. style="width: 100%"
  72. :action="fileUrl"
  73. :data="paramsData"
  74. :headers="myHeader"
  75. multiple
  76. :on-preview="handlePreview"
  77. :on-remove="handleRemove"
  78. :before-remove="beforeRemove"
  79. :on-success="getFileInfo"
  80. :limit="1"
  81. :on-exceed="handleExceed"
  82. >
  83. <el-button v-if="formData.fileList.length == 0" style="margin-top: 10px" type="primary"
  84. >选择文件</el-button
  85. >
  86. </el-upload>
  87. </el-form-item></el-col
  88. >
  89. </el-row>
  90. </el-form>
  91. <div style="text-align: center; padding: 50px 0 20px">
  92. <!-- <button class="bottom-btn" v-if="!isShow" style="background-color: #676fe8" @click="handleAgree">通 过</button>
  93. <button class="bottom-btn" v-if="!isShow" style="background-color: #e13434" @click="handleReturn">退 回</button>
  94. <button class="bottom-btn" style="background-color: #89aac4" @click="handleBack">返 回</button> -->
  95. <el-button type="success" v-if="!isShow" @click="handleAgree" style="background-color: #676fe8;border:none">通过</el-button>
  96. <el-button type="primary" v-if="!isShow" @click="handleReturn" style="background-color: #e13434;border:none">退回</el-button>
  97. <el-button @click="handleBack">返回</el-button>
  98. </div>
  99. </div>
  100. </basic-container>
  101. </template>
  102. <script setup lang="ts">
  103. import { reactive, toRefs, onMounted } from "vue";
  104. import { getInAuditDetail, audit } from "@/api/inAndOut/outAudit/index";
  105. import { getDictItemList } from "@/api/admin/index";
  106. import { Search } from "@element-plus/icons-vue";
  107. import { ElMessage, ElMessageBox } from "element-plus";
  108. import { useRouter, useRoute } from "vue-router";
  109. import { useDict } from "@/hooks/dict";
  110. // import { closeTagAndOpenLastTag } from "@/router/Routermethods";
  111. import store from "@/store";
  112. import { useGetters } from "@/hooks/storeHooks";
  113. import { getQuery } from "@/hooks/detailQuery/index";
  114. const { access_token } = useGetters(["access_token"]);
  115. const { outdound_type, is_available, province_ch } = useDict("outdound_type", "is_available", "province_ch");
  116. const queryData = getQuery("outWarehouseAuditDetail");
  117. const router = useRouter();
  118. const route = useRoute();
  119. const data = reactive({
  120. tableData: [],
  121. auditData: [],
  122. isShow: false,
  123. fileUrl: "/admin/sysFile/uploadVoucher",
  124. myHeader: { Authorization: "Bearer " + access_token.value }
  125. });
  126. let page = reactive({
  127. currentPage: 1,
  128. pageSize: 5,
  129. total: 0
  130. });
  131. let formData = reactive({
  132. opinion: "",
  133. filePart: "",
  134. fileName: "",
  135. fileList: []
  136. });
  137. let paramsData = reactive({
  138. bucket: "bound"
  139. });
  140. let { tableData, auditData, isShow, fileUrl, myHeader } = toRefs(data);
  141. // 获取列表
  142. const getList = () => {
  143. if (queryData.type == "show") {
  144. isShow.value = true;
  145. } else {
  146. isShow.value = false;
  147. }
  148. getInAuditDetail(queryData.id).then((res: any) => {
  149. if (res.code === 0) {
  150. tableData.value = res.data.outboundMaterial;
  151. auditData.value = res.data.outboundStatus;
  152. }
  153. });
  154. };
  155. // 根据码回显中文
  156. const showCh = (value: any, option: any) => {
  157. const filterItem = option.filter((item: any) => item.value == value);
  158. return filterItem.length ? filterItem[0].label : "-";
  159. };
  160. // 通过
  161. const handleAgree = () => {
  162. ElMessageBox.confirm("是否确认通过?", "提示", {
  163. confirmButtonText: "确认",
  164. cancelButtonText: "取消",
  165. type: "warning"
  166. })
  167. .then(() => {
  168. let data = { ...formData, audi: "0", outboundId: queryData.id };
  169. audit(data).then((res: any) => {
  170. if (res.code === 0) {
  171. ElMessage({
  172. type: "success",
  173. message: "提交成功"
  174. });
  175. router.push("/InformationAudit/outWarehouseAudit");
  176. }
  177. });
  178. })
  179. .catch(() => {
  180. ElMessage({
  181. type: "info",
  182. message: "取消提交"
  183. });
  184. });
  185. };
  186. // 退回
  187. const handleReturn = () => {
  188. ElMessageBox.confirm("是否确认退回?", "提示", {
  189. confirmButtonText: "确认",
  190. cancelButtonText: "取消",
  191. type: "warning"
  192. })
  193. .then(() => {
  194. let data = { ...formData, audi: "1", outboundId: queryData.id };
  195. audit(data).then((res: any) => {
  196. if (res.code === 0) {
  197. ElMessage({
  198. type: "success",
  199. message: "提交成功"
  200. });
  201. router.push("/InformationAudit/outWarehouseAudit");
  202. }
  203. });
  204. })
  205. .catch(() => {
  206. ElMessage({
  207. type: "info",
  208. message: "取消提交"
  209. });
  210. });
  211. };
  212. // 返回
  213. const handleBack = () => {
  214. store.commit("DEL_TAG", store.getters.tag);
  215. router.push("/InformationAudit/outWarehouseAudit");
  216. // closeTagAndOpenLastTag();
  217. };
  218. // 附件相关
  219. const getFileInfo = (res: any, file: any, fileList: any) => {
  220. if (fileList.length > 0) {
  221. formData.filePart = fileList[0].response ? fileList[0].response.data.fileName : "";
  222. formData.fileName = fileList[0].name;
  223. }
  224. };
  225. const handleRemove = (file: any, uploadFiles: any) => {
  226. console.log(file, uploadFiles);
  227. };
  228. const handlePreview = (uploadFile: any) => {
  229. console.log(uploadFile);
  230. };
  231. const handleExceed = (files: any, uploadFiles: any) => {
  232. ElMessage.warning(`限制上传一个文件`);
  233. };
  234. const beforeRemove = (uploadFile: any, uploadFiles: any) => {
  235. return ElMessageBox.confirm(`确定移除 ${uploadFile.name} ?`).then(
  236. () => true,
  237. () => false
  238. );
  239. };
  240. const fileDownload = (filePart: any, fileName: string) => {
  241. function createObjectURL(object: any) {
  242. return window.URL ? window.URL.createObjectURL(object) : window.webkitURL.createObjectURL(object);
  243. }
  244. var xhr = new XMLHttpRequest();
  245. var formData = new FormData();
  246. xhr.open("get", "/admin/sysFile/" + filePart);
  247. xhr.setRequestHeader("Authorization", "Bearer " + access_token.value);
  248. xhr.responseType = "blob";
  249. xhr.onload = function (e) {
  250. if (this.status == 200) {
  251. var blob = this.response;
  252. console.log(this.response);
  253. if (window.navigator.msSaveOrOpenBlob) {
  254. navigator.msSaveBlob(blob, fileName);
  255. } else {
  256. var a = document.createElement("a");
  257. var url = createObjectURL(blob);
  258. a.href = url;
  259. a.download = fileName;
  260. document.body.appendChild(a);
  261. a.click();
  262. window.URL.revokeObjectURL(url);
  263. }
  264. }
  265. };
  266. xhr.send(formData);
  267. };
  268. onMounted(() => {
  269. getList();
  270. });
  271. </script>
  272. <style lang="scss" scoped>
  273. .bottom-btn {
  274. width: 150px;
  275. height: 44px;
  276. line-height: 44px;
  277. color: #ffffff;
  278. border: none;
  279. border-radius: 15px;
  280. }
  281. .bottom-btn + .bottom-btn {
  282. margin-left: 20px;
  283. }
  284. .el-form-item {
  285. align-items: center;
  286. }
  287. .fileName {
  288. color: #4281e6;
  289. text-decoration: underline;
  290. cursor: pointer;
  291. }
  292. </style>