jiluxiang.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. <template>
  2. <div class="stepsViewScrollH">
  3. <template v-if="submitStatus == true">
  4. <div class="operateBody">
  5. <el-scrollbar>
  6. <div class="operateBox" v-for="(item, index) in listData">
  7. <div class="inputBox">
  8. <div class="valueBox">
  9. <div class="describeText value">{{ index + 1 }}.记录项:</div>
  10. <div class="inputText">
  11. <el-input
  12. :disabled="
  13. item.addStatus == false && item.updateStatus == false
  14. "
  15. v-model="item.label"
  16. style="width: 240px"
  17. placeholder="请输入"
  18. />
  19. </div>
  20. </div>
  21. <div class="valueBox">
  22. <div class="describeText value">内容:</div>
  23. <div class="inputText">
  24. <el-input
  25. :disabled="
  26. item.addStatus == false && item.updateStatus == false
  27. "
  28. v-model="item.inputValue"
  29. type="textarea"
  30. placeholder="请输入"
  31. maxlength="1000"
  32. />
  33. </div>
  34. </div>
  35. </div>
  36. <div class="operate">
  37. <div class="iconBox">
  38. <div
  39. class="operateText"
  40. v-if="
  41. item.addStatus == false &&
  42. index == listData.length - 1 &&
  43. item.updateStatus == false
  44. "
  45. @click="addFnc"
  46. >
  47. 增加
  48. </div>
  49. <div
  50. v-if="item.addStatus == false && item.updateStatus == false"
  51. class="operateText"
  52. @click="deleteFnc(item.id, index)"
  53. >
  54. 删除
  55. </div>
  56. <div
  57. v-if="item.addStatus == false && item.updateStatus == false"
  58. class="operateText"
  59. @click="updateFnc(item)"
  60. >
  61. 编辑
  62. </div>
  63. <div
  64. v-if="item.addStatus == true || item.updateStatus == true"
  65. class="operateText"
  66. @click="isOkFnc(item, index)"
  67. >
  68. 完成
  69. </div>
  70. <div
  71. v-if="item.addStatus == true || item.updateStatus == true"
  72. class="operateText"
  73. @click="cancelFnc(index, item)"
  74. >
  75. 取消
  76. </div>
  77. </div>
  78. </div>
  79. </div>
  80. <div
  81. @click="addFnc"
  82. class="operateBox"
  83. v-if="listData.length < 1"
  84. style="
  85. height: 80px;
  86. display: flex;
  87. align-items: center;
  88. justify-content: center;
  89. "
  90. >
  91. <el-icon size="30">
  92. <Plus />
  93. </el-icon>
  94. </div>
  95. <div class="btns">
  96. <el-button @click="btn" type="primary" v-if="submitStatus" plain>{{
  97. submitStatus ? "返回 " : "编 辑"
  98. }}</el-button>
  99. </div>
  100. </el-scrollbar>
  101. </div>
  102. </template>
  103. <!-- 展示 -->
  104. <div class="recordBody" v-if="submitStatus == false">
  105. <div class="left" v-if="listData.length > 0">
  106. <el-scrollbar>
  107. <div style="display: flex; flex-wrap: wrap">
  108. <div
  109. @click="showSelectIndex = index"
  110. :class="index == showSelectIndex ? 'infoBox active' : 'infoBox'"
  111. v-for="(item, index) in listData"
  112. :key="item"
  113. >
  114. <div>
  115. <div class="titleText">记录项名:</div>
  116. <div class="describeText">{{ item.label }}</div>
  117. </div>
  118. <div>
  119. <div class="titleText">记录内容:</div>
  120. <div class="describeText textarea">
  121. {{ item.inputValue }}
  122. </div>
  123. </div>
  124. </div>
  125. </div>
  126. </el-scrollbar>
  127. </div>
  128. <div class="right" v-if="listData.length > 0">
  129. <el-scrollbar>
  130. <div class="titleText" style="text-align: center">
  131. {{ listData[showSelectIndex].label }}
  132. </div>
  133. <div class="describeText" style="padding: 0 20px">
  134. {{ listData[showSelectIndex].inputValue }}
  135. </div>
  136. </el-scrollbar>
  137. </div>
  138. <div
  139. style="
  140. height: 100%;
  141. width: 100%;
  142. display: flex;
  143. justify-content: center;
  144. align-items: center;
  145. "
  146. v-if="listData.length == 0"
  147. >
  148. <Empty />
  149. </div>
  150. </div>
  151. <div class="btns">
  152. <el-button @click="btn" type="primary" v-if="!submitStatus" plain>{{
  153. submitStatus ? "返回 " : "编 辑"
  154. }}</el-button>
  155. </div>
  156. </div>
  157. </template>
  158. <script lang="ts" setup>
  159. import {
  160. listAdd,
  161. getList,
  162. listDelete,
  163. listUpdate,
  164. } from "@/api/prosteps/jiluxiang";
  165. import { useProcessStore } from "@/store";
  166. defineOptions({
  167. name: "Jiluxiang",
  168. });
  169. const showSelectIndex = ref(0);
  170. const submitStatus = ref(false);
  171. const store = useProcessStore();
  172. const jianDisabled = ref(true);
  173. const jiaDisabled = ref(false);
  174. const listData = ref([]);
  175. const submitData = ref([]);
  176. const getListData = async () => {
  177. const { data } = await getList({
  178. pageNo: 1,
  179. pageSize: 9999,
  180. processId: Number(store.scanInfo.id),
  181. seqNo: store.scanInfo.seqNo,
  182. operationRecordItemId: Number(store.odersData.operationId),
  183. });
  184. listData.value = data.records;
  185. listData.value.forEach((item) => {
  186. item.addStatus = false;
  187. item.updateStatus = false;
  188. });
  189. };
  190. const item = {
  191. inputValue: "",
  192. label: "",
  193. updateInputValue: "",
  194. updateLabel: "",
  195. processId: Number(store.scanInfo.id),
  196. seqNo: store.scanInfo.seqNo,
  197. operationRecordItemId: Number(store.odersData.operationId),
  198. addStatus: true,
  199. updateStatus: false,
  200. };
  201. const btn = () => {
  202. if (submitStatus.value == true) {
  203. if (
  204. listData.value[listData.value.length - 1].addStatus == true ||
  205. listData.value[listData.value.length - 1].updateStatus == true
  206. ) {
  207. ElMessage.warning("请确认各项记录编辑完成!");
  208. return;
  209. } else {
  210. submitStatus.value = !submitStatus.value;
  211. }
  212. } else {
  213. submitStatus.value = !submitStatus.value;
  214. }
  215. };
  216. const addFnc = (index) => {
  217. listData.value.push({
  218. ...item,
  219. sort: listData.value == 0 ? 1 : listData.value.length,
  220. });
  221. };
  222. const deleteFnc = async (id, index) => {
  223. const { data, code } = await listDelete({
  224. id,
  225. });
  226. if (code == "200") {
  227. ElMessage.success("操作成功!");
  228. listData.value.splice(index, 1);
  229. }
  230. };
  231. const updateFnc = (item) => {
  232. item.updateStatus = true;
  233. item.updateInputValue = item.inputValue;
  234. item.updateLabel = item.label;
  235. };
  236. const isOkFnc = async (item, index) => {
  237. if (item.addStatus == true) {
  238. const { data, code } = await listAdd(item);
  239. if (code == "200") {
  240. ElMessage.success("操作成功!");
  241. item.addStatus = false;
  242. item.id = data.id;
  243. }
  244. } else {
  245. const { data, code } = await listUpdate({
  246. ...item,
  247. inputValue: item.inputValue,
  248. label: item.label,
  249. processId: Number(store.scanInfo.id),
  250. seqNo: store.scanInfo.seqNo,
  251. operationRecordItemId: Number(store.odersData.operationId),
  252. });
  253. if (code == "200") {
  254. ElMessage.success("更新成功!");
  255. item.updateInputValue = "";
  256. item.updateLabel = "";
  257. item.updateStatus = false;
  258. }
  259. }
  260. };
  261. const cancelFnc = (index, item) => {
  262. if (item.addStatus == true) {
  263. listData.value.splice(index, 1);
  264. } else {
  265. item.inputValue = item.updateInputValue;
  266. item.label = item.updateLabel;
  267. item.updateStatus = false;
  268. }
  269. };
  270. onMounted(() => {
  271. getListData();
  272. });
  273. </script>
  274. <style lang="scss" scoped>
  275. .describeText {
  276. color: black;
  277. }
  278. .stepsViewScrollH {
  279. position: relative;
  280. }
  281. .active {
  282. border: 1px solid #0000ff50;
  283. }
  284. .btns {
  285. width: 100%;
  286. height: 70px;
  287. display: flex;
  288. align-items: center;
  289. justify-content: center;
  290. margin-top: 10px;
  291. .el-button {
  292. width: 120px;
  293. border-radius: 25px;
  294. font-size: $f20;
  295. height: 50px;
  296. margin: 0 40px;
  297. }
  298. }
  299. .operateBody {
  300. width: 100%;
  301. height: calc(100%);
  302. }
  303. .recordBody {
  304. width: 100%;
  305. height: calc(100% - 80px);
  306. display: flex;
  307. .left {
  308. width: 50%;
  309. height: calc(100%);
  310. display: flex;
  311. justify-content: space-between;
  312. .infoBox {
  313. display: inline-block;
  314. box-sizing: border-box;
  315. width: 230px;
  316. height: 180px;
  317. background-color: white;
  318. border-radius: 16px;
  319. padding: 20px;
  320. margin: 0 5px;
  321. margin-bottom: 5px;
  322. .textarea {
  323. display: -webkit-box;
  324. -webkit-box-orient: vertical;
  325. -webkit-line-clamp: 2;
  326. overflow: hidden;
  327. text-overflow: ellipsis;
  328. }
  329. }
  330. }
  331. .right {
  332. width: 50%;
  333. background-color: white;
  334. border-radius: 16px;
  335. height: calc(100%);
  336. }
  337. }
  338. .operateBox {
  339. padding: $p20;
  340. background-color: white;
  341. border-radius: 16px;
  342. margin: $p20;
  343. position: relative;
  344. display: flex;
  345. .inputBox {
  346. flex: 1;
  347. height: auto;
  348. border: 1px solid #00000060;
  349. border-radius: 16px;
  350. display: flex;
  351. flex-direction: column;
  352. justify-content: space-evenly;
  353. padding: 0 $p20;
  354. .valueBox {
  355. display: flex;
  356. margin: $p10 0;
  357. .inputText {
  358. flex: 1;
  359. }
  360. .value {
  361. text-align: right;
  362. width: 110px;
  363. }
  364. }
  365. }
  366. .operate {
  367. width: 60px;
  368. height: auto;
  369. @include flex;
  370. .iconBox {
  371. display: flex;
  372. flex-direction: column;
  373. .operateText {
  374. padding: 2px 5px;
  375. cursor: pointer;
  376. font-size: 20px;
  377. }
  378. .operateText:hover {
  379. background-color: var(--el-color-primary);
  380. color: white;
  381. border-radius: 16px;
  382. padding: 0 5px;
  383. }
  384. }
  385. }
  386. }
  387. .el-icon {
  388. width: 60px;
  389. font-weight: bold;
  390. }
  391. </style>