index.vue 11 KB

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