jiluxiang.vue 9.7 KB

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