jiluxiang.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  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. .titleText {
  276. color: var(--ohos-text);
  277. }
  278. .describeText {
  279. color: var(--ohos-text);
  280. }
  281. .stepsViewScrollH {
  282. position: relative;
  283. }
  284. .active {
  285. border: 1px solid #0000ff50;
  286. }
  287. .btns {
  288. width: 100%;
  289. height: 70px;
  290. display: flex;
  291. align-items: center;
  292. justify-content: center;
  293. margin-top: 10px;
  294. .el-button {
  295. width: 120px;
  296. border-radius: 25px;
  297. font-size: $f20;
  298. height: 50px;
  299. margin: 0 40px;
  300. }
  301. }
  302. .operateBody {
  303. width: 100%;
  304. height: calc(100%);
  305. }
  306. .recordBody {
  307. width: 100%;
  308. height: calc(100% - 80px);
  309. display: flex;
  310. .left {
  311. width: 50%;
  312. height: calc(100%);
  313. display: flex;
  314. justify-content: space-between;
  315. .infoBox {
  316. display: inline-block;
  317. box-sizing: border-box;
  318. background-color: var(--ohos-box-bg);
  319. width: 230px;
  320. height: 180px;
  321. border-radius: 16px;
  322. padding: 20px;
  323. margin: 0 5px;
  324. margin-bottom: 5px;
  325. .textarea {
  326. display: -webkit-box;
  327. -webkit-box-orient: vertical;
  328. -webkit-line-clamp: 2;
  329. overflow: hidden;
  330. text-overflow: ellipsis;
  331. }
  332. }
  333. }
  334. .right {
  335. width: 50%;
  336. background-color: var(--ohos-box-bg);
  337. border-radius: 16px;
  338. height: calc(100%);
  339. }
  340. }
  341. .operateBox {
  342. padding: $p20;
  343. background-color: var(--ohos-box-bg);
  344. border-radius: 16px;
  345. margin: $p20;
  346. position: relative;
  347. display: flex;
  348. .inputBox {
  349. flex: 1;
  350. height: auto;
  351. border: 1px solid #00000060;
  352. border-radius: 16px;
  353. display: flex;
  354. flex-direction: column;
  355. justify-content: space-evenly;
  356. padding: 0 $p20;
  357. .valueBox {
  358. display: flex;
  359. margin: $p10 0;
  360. .inputText {
  361. flex: 1;
  362. }
  363. .value {
  364. text-align: right;
  365. width: 110px;
  366. }
  367. }
  368. }
  369. .operate {
  370. width: 60px;
  371. height: auto;
  372. @include flex;
  373. .iconBox {
  374. display: flex;
  375. flex-direction: column;
  376. .operateText {
  377. padding: 2px 5px;
  378. cursor: pointer;
  379. font-size: 20px;
  380. }
  381. .operateText:hover {
  382. background-color: var(--el-color-primary);
  383. color: white;
  384. border-radius: 16px;
  385. padding: 0 5px;
  386. }
  387. }
  388. }
  389. }
  390. .el-icon {
  391. width: 60px;
  392. font-weight: bold;
  393. }
  394. </style>