index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  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">当前检验人:{{ nickName }}</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 nickName = ref(null);
  164. const checkType = ref("first_check");
  165. const editStatus = ref(false);
  166. const editCheck = async (row) => {
  167. editType.value = "edit";
  168. formData.value.checkContent = row.checkContent;
  169. formData.value.checkName = row.checkName;
  170. formData.value.checkCode = row.checkCode;
  171. formData.value.result = row.result;
  172. formData.value.remark = row.remark;
  173. formData.value.id = row.id;
  174. formData.value.seqNoList = [processStore.useSeqNo];
  175. editStatus.value = true;
  176. if (row.filePath) {
  177. setTimeout(() => {
  178. formRef.value.setFileList([{ name: row.fileName }]);
  179. }, 0);
  180. }
  181. };
  182. const search = ref({
  183. limit: 10,
  184. page: 1,
  185. total: 0,
  186. });
  187. const downLoad = async (url) => {
  188. let resUrl = url;
  189. await downloadFile(resUrl, "附件");
  190. };
  191. const addCheck = () => {
  192. formData.value = { ...checkObj };
  193. formRef.value.getSeq();
  194. editStatus.value = true;
  195. editType.value = "add";
  196. };
  197. const check = () => {
  198. return new Promise(async (resolve, reject) => {
  199. await formRef.value.formRef.validate((valid) => {
  200. if (valid) {
  201. resolve();
  202. } else {
  203. ElMessage.error("请检查表单");
  204. reject();
  205. }
  206. });
  207. });
  208. };
  209. const reset = () => {
  210. formData.value = {};
  211. editStatus.value = false;
  212. editType.value = "add";
  213. getPagination();
  214. };
  215. const addCheckAsync = async () => {
  216. const { data, code } = await addCheckList({
  217. ...formData.value,
  218. checkType: checkType.value,
  219. operationId: processStore.odersData.operationId,
  220. workOrderCode: processStore.odersData.workOrderCode,
  221. operator: checkName.value,
  222. processId: processStore.scanInfo.id,
  223. fileName: fileName.value,
  224. operationName: processStore.scanInfo.operationName,
  225. });
  226. if (code == "200") {
  227. ElMessage.success("操作成功!");
  228. }
  229. };
  230. const deleteCheck = (id) => {
  231. deleteCheckAsync(id);
  232. };
  233. const deleteCheckAsync = async (id) => {
  234. const { data, code } = await deleteCheckList({
  235. id,
  236. });
  237. if (code == "200") {
  238. ElMessage.success("操作成功!");
  239. getPagination();
  240. }
  241. };
  242. const editCheckAsync = async () => {
  243. const { data, code } = await editCheckList({
  244. ...formData.value,
  245. checkType: checkType.value,
  246. operationId: processStore.odersData.operationId,
  247. workOrderCode: processStore.odersData.workOrderCode,
  248. operator: checkName.value,
  249. processId: processStore.scanInfo.id,
  250. fileName: fileName.value,
  251. operationName: processStore.scanInfo.operationName,
  252. });
  253. if (code == "200") {
  254. ElMessage.success("操作成功!");
  255. }
  256. };
  257. const fileName = ref("");
  258. provide("fileName", fileName);
  259. const submit = async () => {
  260. check().then(async () => {
  261. if (editType.value == "add") {
  262. await addCheckAsync();
  263. reset();
  264. } else {
  265. await editCheckAsync();
  266. reset();
  267. }
  268. });
  269. };
  270. const checkObj = {
  271. checkContent: "",
  272. checkName: "",
  273. checkType: "",
  274. filePath: "",
  275. result: "",
  276. seqNoList: [],
  277. };
  278. const dataList = ref([]);
  279. const getPagination = async () => {
  280. const { data } = await getCheckList({
  281. checkType: checkType.value,
  282. pageNo: search.value.page,
  283. pageSize: search.value.limit,
  284. operationId: processStore.odersData.operationId,
  285. workOrderCode: processStore.odersData.workOrderCode,
  286. seqNo: processStore.useSeqNo,
  287. operationName: processStore.scanInfo.operationName,
  288. });
  289. search.value.total = data.totalCount;
  290. dataList.value = data.records;
  291. };
  292. const inspectStore = useInspectStore();
  293. const processStore = useProcessStore();
  294. const editType = ref("add");
  295. const toBack = () => {
  296. editStatus.value = false;
  297. };
  298. //add 或者edit
  299. const options = [
  300. {
  301. value: "first_check",
  302. label: "首检",
  303. },
  304. {
  305. value: "inspection",
  306. label: "巡检",
  307. },
  308. /*{
  309. value: "self_check",
  310. label: "自检",
  311. },*/
  312. {
  313. value: "special_inspection",
  314. label: "专检",
  315. },
  316. /* {
  317. value: "mutual_inspection",
  318. label: "互检",
  319. },*/
  320. ];
  321. const inputValue = ref("");
  322. const handleSubmit = () => {
  323. inputValue.value = inputValue.value.trim();
  324. checkUserVal();
  325. };
  326. const logOff = () => {
  327. checkName.value = "";
  328. inspectStore.checkName = "";
  329. nickName.value = ""
  330. };
  331. // const drawingData = ref<any>([]);
  332. const checkUserVal = async () => {
  333. setTimeout(() => {
  334. inputValue.value = "";
  335. }, 0);
  336. const { data, code, msg } = await checkUser({
  337. employeeCode: inputValue.value,
  338. });
  339. if (code == "200") {
  340. ElMessage.success("记录成功!请开展检验操作");
  341. inspectStore.checkName = data.userName;
  342. checkName.value = data.userName;
  343. nickName.value = data.nickName;
  344. } else {
  345. ElMessage.error(msg);
  346. }
  347. };
  348. // const baseUrl = import.meta.env.VITE_APP_UPLOAD_URL;
  349. onMounted(() => {
  350. if (inspectStore.checkName) {
  351. checkName.value = inspectStore.checkName;
  352. }
  353. });
  354. watch(checkName, (val) => {
  355. if (val !== "") {
  356. getPagination();
  357. }
  358. });
  359. onUnmounted(() => {
  360. inspectStore.checkName = "";
  361. });
  362. </script>
  363. <style lang="scss" scoped>
  364. .opera {
  365. font-size: 20px;
  366. margin-right: 10px;
  367. cursor: pointer;
  368. color: rgb(64, 158, 255);
  369. }
  370. .sureBtn {
  371. border-radius: 25px;
  372. font-size: 20px;
  373. font-size: 500;
  374. height: 50px;
  375. }
  376. .body {
  377. width: 100vw;
  378. height: calc(100vh - 120px);
  379. display: flex;
  380. align-items: center;
  381. justify-content: center;
  382. .checkBody {
  383. width: 30vw;
  384. align-items: center;
  385. justify-content: center;
  386. }
  387. .checkForm {
  388. width: 100%;
  389. height: 100%;
  390. display: flex;
  391. flex-direction: column;
  392. .headerName {
  393. width: 100%;
  394. height: 40px;
  395. background-color: white;
  396. border-radius: 20px;
  397. lighting-color: 40px;
  398. padding: 0 20px;
  399. display: flex;
  400. justify-content: space-between;
  401. align-items: center;
  402. }
  403. .content {
  404. flex: 1;
  405. padding: 20px;
  406. .form {
  407. width: 800px;
  408. height: 100%;
  409. margin: 0 auto;
  410. background-color: white;
  411. border-radius: 16px;
  412. display: flex;
  413. flex-direction: column;
  414. .formContent {
  415. flex: 1;
  416. }
  417. .btns {
  418. width: 100%;
  419. height: 60px;
  420. display: flex;
  421. align-items: center;
  422. padding: 0 20%;
  423. justify-content: space-evenly;
  424. }
  425. }
  426. }
  427. }
  428. }
  429. </style>