index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. <template>
  2. <div class="body">
  3. <!-- <div v-for="(box, index) in drawingData" :key="index" class="suit-box">
  4. <div class="pdf-box">
  5. <PDFView
  6. :need-to-show-pdf="true"
  7. :pdf-source="baseUrl + box.pdfPath"
  8. />
  9. </div>
  10. <div class="suit-title">{{ box?.drawingTitle }}</div>
  11. <div class="suit-desc">{{ box?.created }}</div>
  12. </div> -->
  13. <div v-if="!checkName" class="checkBody">
  14. <div class="titleText" style="text-align: center; margin-bottom: 20px">
  15. 请先扫描铭牌或输入工牌号:
  16. </div>
  17. <ScanCodeInput v-model="inputValue" @keyup.enter="handleSubmit" />
  18. </div>
  19. <div v-else class="checkForm">
  20. <div v-if="!editStatus" class="headerName">
  21. <div class="titleText">当前检验人:{{ checkName }}</div>
  22. <div
  23. class="titleText"
  24. style="margin-right: 15%; display: flex; align-items: center"
  25. >
  26. 检验类型:
  27. <el-select
  28. v-model="checkType"
  29. placeholder="Select"
  30. style="width: 100px; font-size: 16px"
  31. @change="
  32. search.page = 1;
  33. getPagination();
  34. "
  35. >
  36. <el-option
  37. v-for="item in options"
  38. :key="item.value"
  39. :label="item.label"
  40. :value="item.value"
  41. style="color: black; font-size: 16px"
  42. />
  43. </el-select>
  44. </div>
  45. <div
  46. class="titleText"
  47. style="color: red; cursor: pointer"
  48. @click="logOff"
  49. >
  50. 注销
  51. </div>
  52. </div>
  53. <div v-if="!editStatus" class="content">
  54. <div>
  55. <el-button
  56. class="sureBtn"
  57. style="margin-bottom: 10px"
  58. type="success"
  59. @click="addCheck"
  60. >新 增
  61. </el-button>
  62. </div>
  63. <el-table
  64. :data="dataList"
  65. style="height: calc(100vh - 250px); border-radius: 16px"
  66. >
  67. <el-table-column label="序号" type="index" width="80" />
  68. <el-table-column label="检验项名称" prop="checkName" />
  69. <el-table-column label="检验项内容" prop="checkContent" />
  70. <el-table-column label="流转卡号" prop="seqNo" />
  71. <el-table-column label="备注" prop="remark" />
  72. <!-- <el-table-column label="附件" prop="filePath">
  73. <template #default="scope">
  74. <span
  75. v-if="scope.row.filePath"
  76. class="opera"
  77. @click="downLoad(scope.row.filePath)"
  78. >下载</span
  79. >
  80. <span v-else>无附件</span>
  81. </template>
  82. </el-table-column> -->
  83. <el-table-column label="结果" prop="result">
  84. <template #default="scope">
  85. <span
  86. :style="{ color: scope.row.result == '1' ? 'green' : 'red' }"
  87. >{{ scope.row.result == "1" ? "合格" : "不合格" }}</span
  88. >
  89. </template>
  90. </el-table-column>
  91. <el-table-column label="操作" width="180">
  92. <template #default="scope">
  93. <span class="opera" @click="editCheck(scope.row)">编辑</span>
  94. <span
  95. class="opera"
  96. style="color: red"
  97. @click="deleteCheck(scope.row.id)"
  98. >删除</span
  99. >
  100. </template>
  101. </el-table-column>
  102. <template #empty>
  103. <div class="empty">
  104. <Empty />
  105. </div>
  106. </template>
  107. </el-table>
  108. <Pagination
  109. :limit="search.limit"
  110. :page="search.page"
  111. :position="'right'"
  112. :total="search.total"
  113. @pagination="getPagination"
  114. />
  115. </div>
  116. <div v-if="editStatus" class="headerName">
  117. <div class="titleText">当前检验人:{{ checkName }}</div>
  118. <div
  119. class="titleText"
  120. style="margin-right: 15%; display: flex; align-items: center"
  121. >
  122. 操作类型:{{ editType == "add" ? "新增" : "修改" }}
  123. </div>
  124. <div></div>
  125. </div>
  126. <div v-show="editStatus" class="content">
  127. <div class="form">
  128. <div class="formContent">
  129. <el-scrollbar style="height: calc(100vh - 200px); padding: 20px">
  130. <CheckForm ref="formRef" v-model="formData" />
  131. </el-scrollbar>
  132. </div>
  133. <div class="btns">
  134. <el-button class="sureBtn" type="primary" @click="submit"
  135. >提 交
  136. </el-button>
  137. <el-button class="sureBtn" type="info" @click="toBack"
  138. >返 回
  139. </el-button>
  140. </div>
  141. </div>
  142. </div>
  143. </div>
  144. </div>
  145. </template>
  146. <script setup>
  147. import {
  148. addCheckList,
  149. checkUser,
  150. deleteCheckList,
  151. editCheckList,
  152. getCheckList,
  153. } from "@/api/inspect";
  154. import { useProcessStore } from "@/store/modules/processView";
  155. import { useInspectStore } from "@/store/modules/inspect";
  156. import { downloadFile } from "@/utils/downLoad";
  157. import CheckForm from "./components/checkForm.vue";
  158. const formRef = ref(null);
  159. const formData = ref({});
  160. const checkName = ref(null);
  161. const checkType = ref("first_check");
  162. const editStatus = ref(false);
  163. const editCheck = async (row) => {
  164. editType.value = "edit";
  165. formData.value.checkContent = row.checkContent;
  166. formData.value.checkName = row.checkName;
  167. formData.value.result = row.result;
  168. formData.value.remark = row.remark;
  169. formData.value.seqNoList = [processStore.useSeqNo];
  170. editStatus.value = true;
  171. if (row.filePath) {
  172. setTimeout(() => {
  173. formRef.value.setFileList([{ name: row.fileName }]);
  174. }, 0);
  175. }
  176. };
  177. const search = ref({
  178. limit: 10,
  179. page: 1,
  180. total: 0,
  181. });
  182. const downLoad = async (url) => {
  183. let resUrl = url;
  184. await downloadFile(resUrl, "附件");
  185. };
  186. const addCheck = () => {
  187. formData.value = { ...checkObj };
  188. formRef.value.getSeq();
  189. editStatus.value = true;
  190. editType.value = "add";
  191. };
  192. const check = () => {
  193. return new Promise(async (resolve, reject) => {
  194. await formRef.value.formRef.validate((valid) => {
  195. if (valid) {
  196. resolve();
  197. } else {
  198. ElMessage.error("请检查表单");
  199. reject();
  200. }
  201. });
  202. });
  203. };
  204. const reset = () => {
  205. formData.value = {};
  206. editStatus.value = false;
  207. editType.value = "add";
  208. getPagination();
  209. };
  210. const addCheckAsync = async () => {
  211. const { data, code } = await addCheckList({
  212. ...formData.value,
  213. checkType: checkType.value,
  214. operationId: processStore.odersData.operationId,
  215. workOrderCode: processStore.odersData.workOrderCode,
  216. operator: checkName.value,
  217. processId: processStore.scanInfo.id,
  218. fileName: fileName.value,
  219. operationName: processStore.scanInfo.operationName,
  220. });
  221. if (code == "200") {
  222. ElMessage.success("操作成功!");
  223. }
  224. };
  225. const deleteCheck = (id) => {
  226. deleteCheckAsync(id);
  227. };
  228. const deleteCheckAsync = async (id) => {
  229. const { data, code } = await deleteCheckList({
  230. id,
  231. });
  232. if (code == "200") {
  233. ElMessage.success("操作成功!");
  234. getPagination();
  235. }
  236. };
  237. const editCheckAsync = async () => {
  238. const { data, code } = await editCheckList({
  239. ...formData.value,
  240. checkType: checkType.value,
  241. operationId: processStore.odersData.operationId,
  242. workOrderCode: processStore.odersData.workOrderCode,
  243. operator: checkName.value,
  244. processId: processStore.scanInfo.id,
  245. fileName: fileName.value,
  246. operationName: processStore.scanInfo.operationName,
  247. });
  248. if (code == "200") {
  249. ElMessage.success("操作成功!");
  250. }
  251. };
  252. const fileName = ref("");
  253. provide("fileName", fileName);
  254. const submit = async () => {
  255. check().then(async () => {
  256. if (editType.value == "add") {
  257. await addCheckAsync();
  258. reset();
  259. } else {
  260. await editCheckAsync();
  261. reset();
  262. }
  263. });
  264. };
  265. const checkObj = {
  266. checkContent: "",
  267. checkName: "",
  268. checkType: "",
  269. filePath: "",
  270. result: "",
  271. seqNoList: [],
  272. };
  273. const dataList = ref([]);
  274. const getPagination = async () => {
  275. const { data } = await getCheckList({
  276. checkType: checkType.value,
  277. pageNo: search.value.page,
  278. pageSize: search.value.limit,
  279. operationId: processStore.odersData.operationId,
  280. workOrderCode: processStore.odersData.workOrderCode,
  281. seqNo: processStore.useSeqNo,
  282. operationName: processStore.scanInfo.operationName,
  283. });
  284. search.value.total = data.totalCount;
  285. dataList.value = data.records;
  286. };
  287. const inspectStore = useInspectStore();
  288. const processStore = useProcessStore();
  289. const editType = ref("add");
  290. const toBack = () => {
  291. editStatus.value = false;
  292. };
  293. //add 或者edit
  294. const options = [
  295. {
  296. value: "first_check",
  297. label: "首检",
  298. },
  299. {
  300. value: "inspection",
  301. label: "巡检",
  302. },
  303. {
  304. value: "self_check",
  305. label: "自检",
  306. },
  307. {
  308. value: "special_inspection",
  309. label: "专检",
  310. },
  311. {
  312. value: "mutual_inspection",
  313. label: "互检",
  314. },
  315. ];
  316. const inputValue = ref("");
  317. const handleSubmit = () => {
  318. inputValue.value = inputValue.value.trim();
  319. checkUserVal();
  320. };
  321. const logOff = () => {
  322. checkName.value = "";
  323. inspectStore.checkName = "";
  324. };
  325. // const drawingData = ref<any>([]);
  326. const checkUserVal = async () => {
  327. setTimeout(() => {
  328. inputValue.value = "";
  329. }, 0);
  330. const { data, code, msg } = await checkUser({
  331. employeeCode: inputValue.value,
  332. });
  333. if (code == "200") {
  334. ElMessage.success("记录成功!请开展检验操作");
  335. inspectStore.checkName = data.userName;
  336. checkName.value = data.userName;
  337. } else {
  338. ElMessage.error(msg);
  339. }
  340. };
  341. // const baseUrl = import.meta.env.VITE_APP_UPLOAD_URL;
  342. onMounted(() => {
  343. if (inspectStore.checkName) {
  344. checkName.value = inspectStore.checkName;
  345. }
  346. });
  347. watch(checkName, (val) => {
  348. if (val !== "") {
  349. getPagination();
  350. }
  351. });
  352. onUnmounted(() => {
  353. inspectStore.checkName = "";
  354. });
  355. </script>
  356. <style lang="scss" scoped>
  357. .opera {
  358. font-size: 20px;
  359. margin-right: 10px;
  360. cursor: pointer;
  361. color: rgb(64, 158, 255);
  362. }
  363. .sureBtn {
  364. border-radius: 16px;
  365. font-size: 16px;
  366. font-size: 500;
  367. }
  368. .body {
  369. width: 100vw;
  370. height: calc(100vh - 120px);
  371. display: flex;
  372. align-items: center;
  373. justify-content: center;
  374. .checkBody {
  375. width: 30vw;
  376. align-items: center;
  377. justify-content: center;
  378. }
  379. .checkForm {
  380. width: 100%;
  381. height: 100%;
  382. display: flex;
  383. flex-direction: column;
  384. .headerName {
  385. width: 100%;
  386. height: 40px;
  387. background-color: white;
  388. border-radius: 20px;
  389. lighting-color: 40px;
  390. padding: 0 20px;
  391. display: flex;
  392. justify-content: space-between;
  393. align-items: center;
  394. }
  395. .content {
  396. flex: 1;
  397. padding: 20px;
  398. .form {
  399. width: 800px;
  400. height: 100%;
  401. margin: 0 auto;
  402. background-color: white;
  403. border-radius: 16px;
  404. display: flex;
  405. flex-direction: column;
  406. .formContent {
  407. flex: 1;
  408. }
  409. .btns {
  410. width: 100%;
  411. height: 60px;
  412. display: flex;
  413. align-items: center;
  414. padding: 0 20%;
  415. justify-content: space-evenly;
  416. }
  417. }
  418. }
  419. }
  420. }
  421. </style>