detail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  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="inboundType" label="入库类型" header-align="center" align="center">
  7. <template #default="scope">
  8. {{ scope.row.inboundType ? showCh(scope.row.inboundType, indound_type) : scope.row.inboundType }}
  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="inboundTime" label="入库日期" header-align="center" align="center" />
  17. <el-table-column prop="unitPrice" label="单价(元)" header-align="center" align="center" />
  18. <el-table-column prop="totalPrice" label="价值(万元)" header-align="center" align="center" />
  19. <el-table-column prop="isAvailable" label="是否可用" header-align="center" align="center">
  20. <template #default="scope">
  21. {{ scope.row.isAvailable ? showCh(scope.row.isAvailable, is_available) : scope.row.isAvailable }}
  22. </template>
  23. </el-table-column>
  24. <el-table-column label="附件上传" header-align="center" align="center" width="160">
  25. <template #default="scope">
  26. <span class="fileName" @click="handlePreview1(scope.row.filePart)">{{ scope.row.fileName }}</span>
  27. </template>
  28. </el-table-column>
  29. <el-table-column prop="remarks" label="备注" header-align="center" align="center" />
  30. </el-table>
  31. </el-row>
  32. <div style="padding: 30px 40px 0">
  33. <el-row v-if="auditData && auditData.length > 0">
  34. <el-table :data="auditData" style="width: 100%" stripe border>
  35. <el-table-column prop="warehouse" label="审核部门" header-align="center" align="center" />
  36. <el-table-column prop="opinion" label="审核意见" header-align="center" align="center" />
  37. <el-table-column label="附件" header-align="center" align="center">
  38. <template #default="scope">
  39. <span class="fileName" @click="handlePreview1(scope.row.filePart)">{{ scope.row.fileName }}</span>
  40. </template>
  41. </el-table-column>
  42. <el-table-column prop="auditingTime" label="审核时间" header-align="center" align="center" />
  43. </el-table>
  44. </el-row>
  45. <el-form :model="formData" v-if="!isShow" label-width="100px" class="whole_form">
  46. <el-row class="audit-form" style="margin-top: 50px">
  47. <el-col :span="24">
  48. <el-form-item label="审核意见:">
  49. <el-input
  50. type="textarea"
  51. rows="4"
  52. v-model="formData.opinion"
  53. placeholder="请输入"
  54. style="width: 100%"
  55. /> </el-form-item
  56. ></el-col>
  57. <el-col :span="24">
  58. <el-form-item label="附件上传:">
  59. <el-upload
  60. v-model:file-list="formData.fileList"
  61. class="upload-demo"
  62. style="width: 100%"
  63. :action="fileUrl"
  64. :data="paramsData"
  65. :headers="myHeader"
  66. multiple
  67. :on-preview="handlePreview"
  68. :on-remove="handleRemove"
  69. :before-remove="beforeRemove"
  70. :on-success="getFileInfo"
  71. :on-error="errorUpload"
  72. :before-upload="beforeUpload"
  73. :limit="1"
  74. :on-exceed="handleExceed"
  75. >
  76. <el-button v-if="formData.fileList.length == 0" style="margin-top: 10px" type="primary"
  77. >选择文件</el-button
  78. >
  79. </el-upload>
  80. </el-form-item></el-col
  81. >
  82. </el-row>
  83. </el-form>
  84. <div style="text-align: center; padding: 50px 0 20px">
  85. <!-- <button class="bottom-btn" v-if="!isShow" style="background-color: #676fe8" @click="handleAgree">通 过</button>
  86. <button class="bottom-btn" v-if="!isShow" style="background-color: #e13434" @click="handleReturn">退 回</button>
  87. <button class="bottom-btn" style="background-color: #89aac4" @click="handleBack">返 回</button> -->
  88. <el-button type="success" v-if="!isShow" @click="handleAgree" style="background-color: #676fe8; border: none"
  89. >通过</el-button
  90. >
  91. <el-button type="primary" v-if="!isShow" @click="handleReturn" style="background-color: #e13434; border: none"
  92. >退回</el-button
  93. >
  94. <el-button @click="handleBack">返回</el-button>
  95. </div>
  96. </div>
  97. </basic-container>
  98. </template>
  99. <script setup lang="ts">
  100. import { reactive, toRefs, onMounted } from "vue";
  101. import { getInAuditDetail, audit } from "@/api/inAndOut/inAudit/index";
  102. import { getDictItemList } from "@/api/admin/index";
  103. import { Search } from "@element-plus/icons-vue";
  104. import { ElMessage, ElMessageBox } from "element-plus";
  105. import type { UploadProps } from "element-plus";
  106. import { useRouter, useRoute } from "vue-router";
  107. import { useDict } from "@/hooks/dict";
  108. // import { closeTagAndOpenLastTag } from '@/router/Routermethods';
  109. import store from "@/store";
  110. import { useGetters } from "@/hooks/storeHooks";
  111. import { getQuery } from "@/hooks/detailQuery/index";
  112. import { sysFile } from "@/api/inAndOut/formationFilling/in";
  113. const { access_token } = useGetters(["access_token"]);
  114. const { indound_type, is_available } = useDict("indound_type", "is_available");
  115. const queryData = getQuery("enterWarehouseAuditDetail");
  116. const router = useRouter();
  117. const route = useRoute();
  118. const data = reactive({
  119. tableData: [],
  120. auditData: [],
  121. isShow: false,
  122. fileUrl: "/admin/sysFile/uploadVoucher",
  123. myHeader: { Authorization: "Bearer " + access_token.value }
  124. });
  125. let page = reactive({
  126. currentPage: 1,
  127. pageSize: 5,
  128. total: 0
  129. });
  130. let formData = reactive({
  131. opinion: "",
  132. filePart: "",
  133. fileName: "",
  134. fileList: []
  135. });
  136. let paramsData = reactive({
  137. bucket: "bound"
  138. });
  139. let { tableData, auditData, isShow, fileUrl, myHeader } = toRefs(data);
  140. // 获取列表
  141. const getList = () => {
  142. if (queryData.type == "show") {
  143. isShow.value = true;
  144. } else {
  145. isShow.value = false;
  146. }
  147. getInAuditDetail(queryData.id).then((res: any) => {
  148. if (res.code === 0) {
  149. tableData.value = res.data.inboundMaterial;
  150. auditData.value = res.data.inboundStatus;
  151. }
  152. });
  153. };
  154. // 根据码回显中文
  155. const showCh = (value: any, option: any) => {
  156. const filterItem = option.filter((item: any) => item.value == value);
  157. return filterItem.length ? filterItem[0].label : "-";
  158. };
  159. // 通过
  160. const handleAgree = () => {
  161. ElMessageBox.confirm("是否确认通过?", "提示", {
  162. confirmButtonText: "确认",
  163. cancelButtonText: "取消",
  164. type: "warning"
  165. })
  166. .then(() => {
  167. let data = { ...formData, audi: "0", inboundId: queryData.id };
  168. audit(data).then((res: any) => {
  169. if (res.code === 0) {
  170. ElMessage({
  171. type: "success",
  172. message: "提交成功"
  173. });
  174. router.push("/InformationAudit/enterWarehouseAudit");
  175. }
  176. });
  177. })
  178. .catch(() => {
  179. ElMessage({
  180. type: "info",
  181. message: "取消提交"
  182. });
  183. });
  184. };
  185. // 退回
  186. const handleReturn = () => {
  187. ElMessageBox.confirm("是否确认退回?", "提示", {
  188. confirmButtonText: "确认",
  189. cancelButtonText: "取消",
  190. type: "warning"
  191. })
  192. .then(() => {
  193. let data = { ...formData, audi: "1", inboundId: queryData.id };
  194. audit(data).then((res: any) => {
  195. if (res.code === 0) {
  196. ElMessage({
  197. type: "success",
  198. message: "提交成功"
  199. });
  200. router.push("/InformationAudit/outWarehouseAudit");
  201. }
  202. });
  203. })
  204. .catch(() => {
  205. ElMessage({
  206. type: "info",
  207. message: "取消提交"
  208. });
  209. });
  210. };
  211. // 返回
  212. const handleBack = () => {
  213. store.commit("DEL_TAG", store.getters.tag);
  214. router.push("/InformationAudit/enterWarehouseAudit");
  215. // closeTagAndOpenLastTag()
  216. };
  217. // 附件相关
  218. const getFileInfo = (res: any, file: any, fileList: any) => {
  219. if (fileList.length > 0) {
  220. formData.filePart = fileList[0].response
  221. ? fileList[0].response.data.bucketName + "/" + fileList[0].response.data.fileName
  222. : "";
  223. formData.fileName = fileList[0].name;
  224. }
  225. };
  226. const handleRemove = (file: any, uploadFiles: any) => {
  227. console.log(file, uploadFiles);
  228. };
  229. const handlePreview = (uploadFile: any) => {
  230. console.log(uploadFile);
  231. };
  232. const handleExceed = (files: any, uploadFiles: any) => {
  233. ElMessage.warning(`限制上传一个文件`);
  234. };
  235. const beforeRemove = (uploadFile: any, uploadFiles: any) => {
  236. // return ElMessageBox.confirm(`确定移除 ${uploadFile.name} ?`).then(
  237. // () => true,
  238. // () => false
  239. // );
  240. };
  241. const errorUpload = (err: any, file: any, fileList: any) => {
  242. ElMessage.error("文件上传失败,UploadAjaxError:" + JSON.parse(JSON.stringify(err)).status);
  243. };
  244. // 上传前对附件进行的操作
  245. const beforeUpload: UploadProps["beforeUpload"] = (file) => {
  246. // const typeList = ".pdf.jpg.png.gif.jpeg.PDF.JPG.PNG.GIF.JPEG";
  247. const typeList = ".pdf"; //限制为pdf格式
  248. const { name, type } = fileNameDispose(file.name);
  249. if (!typeList.includes(type)) {
  250. ElMessage.error("仅支持pdf类型文件,请重新上传。");
  251. return false;
  252. }
  253. if (name.length > 30) {
  254. ElMessage.error("文件名不可超30字,请重新命名后再上传。");
  255. return false;
  256. }
  257. const isLt20M = file.size / 1024 / 1024 < 100;
  258. if (!isLt20M) {
  259. ElMessage.error("文件大小不可超过 100MB。");
  260. return false;
  261. }
  262. return true;
  263. };
  264. // 获取上传附件的名字和类型
  265. const fileNameDispose = (name: string) => {
  266. const arr = name.split(".");
  267. if (arr.length === 2) {
  268. return { name: arr[0], type: arr[1] };
  269. } else {
  270. const type = arr.splice(arr.length - 1, 1)[0];
  271. const name = arr.join(".");
  272. return { name, type };
  273. }
  274. };
  275. const fileDownload = (filePart: any, fileName: string) => {
  276. function createObjectURL(object: any) {
  277. return window.URL ? window.URL.createObjectURL(object) : window.webkitURL.createObjectURL(object);
  278. }
  279. var xhr = new XMLHttpRequest();
  280. var formData = new FormData();
  281. xhr.open("get", "/admin/sysFile/" + filePart);
  282. xhr.setRequestHeader("Authorization", "Bearer " + access_token.value);
  283. xhr.responseType = "blob";
  284. xhr.onload = function (e) {
  285. if (this.status == 200) {
  286. var blob = this.response;
  287. console.log(this.response);
  288. if (window.navigator.msSaveOrOpenBlob) {
  289. navigator.msSaveBlob(blob, fileName);
  290. } else {
  291. var a = document.createElement("a");
  292. var url = createObjectURL(blob);
  293. a.href = url;
  294. a.download = fileName;
  295. document.body.appendChild(a);
  296. a.click();
  297. window.URL.revokeObjectURL(url);
  298. }
  299. }
  300. };
  301. xhr.send(formData);
  302. };
  303. const handlePreview1 = (file: any) => {
  304. if (file) {
  305. sysFile(file).then((res: any) => {
  306. const blob = new Blob([res], { type: "application/pdf;charset=UTF-8" });
  307. const bFile = URL.createObjectURL(blob);
  308. window.open(bFile);
  309. });
  310. }
  311. };
  312. onMounted(() => {
  313. getList();
  314. });
  315. </script>
  316. <style lang="scss" scoped>
  317. .bottom-btn {
  318. width: 150px;
  319. height: 44px;
  320. line-height: 44px;
  321. color: #ffffff;
  322. border: none;
  323. border-radius: 15px;
  324. }
  325. .bottom-btn + .bottom-btn {
  326. margin-left: 20px;
  327. }
  328. .el-form-item {
  329. align-items: center;
  330. }
  331. .fileName {
  332. color: #4281e6;
  333. text-decoration: underline;
  334. cursor: pointer;
  335. }
  336. </style>