add.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. <template>
  2. <div class="form" style="padding-bottom: 60px">
  3. <van-nav-bar
  4. :title="$t('receive.name')"
  5. :left-text="$t('common.back')"
  6. left-arrow
  7. @click-left="onClickLeft"
  8. >
  9. </van-nav-bar>
  10. <testForm
  11. v-model="formData.data"
  12. :formOption="formOption"
  13. :formConfig="formConfig"
  14. :rules="rules"
  15. @onSubmit="onSubmit"
  16. @otherBtnClick="otherBtnClick"
  17. ref="formDom"
  18. >
  19. <template #productRemark>
  20. <div style="width: 100%">
  21. {{ formData.data.productRemark }}
  22. </div>
  23. </template>
  24. <template #fileTwo>
  25. <div
  26. style="width: 100%"
  27. v-if="
  28. formData.data.fileListTwo && formData.data.fileListTwo.length > 0
  29. "
  30. >
  31. <span
  32. v-for="item in formData.data.fileListTwo"
  33. :key="item.id"
  34. @click="onPreviewFile(item)"
  35. style="margin-right: 10px; cursor: pointer; color: #409eff"
  36. >
  37. {{ item.name }}
  38. </span>
  39. </div>
  40. <div v-else>无</div>
  41. </template>
  42. <template #fileThree>
  43. <div
  44. style="width: 100%"
  45. v-if="
  46. formData.data.fileListThree &&
  47. formData.data.fileListThree.length > 0
  48. "
  49. >
  50. <span
  51. v-for="item in formData.data.fileListThree"
  52. :key="item.id"
  53. @click="onPreviewFile(item)"
  54. style="margin-right: 10px; cursor: pointer; color: #409eff"
  55. >
  56. {{ item.name }}
  57. </span>
  58. </div>
  59. <div v-else>无</div>
  60. </template>
  61. </testForm>
  62. </div>
  63. </template>
  64. <script setup>
  65. import { ref, reactive, getCurrentInstance, onMounted } from "vue";
  66. import { showSuccessToast, showFailToast } from "vant";
  67. import { showConfirmDialog } from "vant";
  68. import { useRoute } from "vue-router";
  69. import testForm from "@/components/testForm/index.vue";
  70. const proxy = getCurrentInstance().proxy;
  71. const route = useRoute();
  72. const formDom = ref(null);
  73. const formData = reactive({
  74. data: {
  75. list: [],
  76. },
  77. });
  78. const rules = {
  79. warehouseName: [
  80. { required: true, message: proxy.t("receive.warehouseNameCanNotBeEmpty") },
  81. ],
  82. productName: [
  83. { required: true, message: proxy.t("receive.itemNameCanNotBeEmpty") },
  84. ],
  85. quantity: [
  86. {
  87. required: true,
  88. message: proxy.t("receive.warehousingQuantityCanNotBeEmpty"),
  89. },
  90. ],
  91. };
  92. const formOption = reactive({
  93. readonly: false, //用于控制整个表单是否只读
  94. disabled: false,
  95. labelAlign: "top",
  96. scroll: true,
  97. labelWidth: "62pk",
  98. submitBtnText: proxy.t("receive.confirmReceipt"),
  99. otherBtn: false,
  100. otherBtnText: "退回前道工序",
  101. btnConfig: {
  102. isNeed: false,
  103. prop: "list",
  104. plain: true,
  105. listTitle: "",
  106. listConfig: [],
  107. clickFn: () => {},
  108. },
  109. });
  110. const formConfig = reactive([
  111. {
  112. type: "input",
  113. itemType: "text",
  114. label: proxy.t("receive.productName"),
  115. prop: "productName",
  116. readonly: true,
  117. },
  118. {
  119. type: "input",
  120. itemType: "text",
  121. label: "规格型号",
  122. prop: "productSpec",
  123. readonly: true,
  124. },
  125. {
  126. type: "input",
  127. itemType: "text",
  128. label: proxy.t("receive.productSN"),
  129. prop: "productSn",
  130. readonly: true,
  131. },
  132. {
  133. type: "slot",
  134. itemType: "textarea",
  135. label: "产品备注",
  136. slotName: "productRemark",
  137. readonly: true,
  138. },
  139. {
  140. type: "input",
  141. itemType: "text",
  142. label: "当前工序",
  143. prop: "productionProcessesName",
  144. readonly: true,
  145. },
  146. {
  147. type: "slot",
  148. label: "生产工序资料",
  149. slotName: "fileTwo",
  150. },
  151. {
  152. type: "slot",
  153. label: "工单附件",
  154. slotName: "fileThree",
  155. },
  156. {
  157. type: "upload",
  158. label: "完工拍摄",
  159. prop: "fileList",
  160. showUpload: false,
  161. },
  162. {
  163. type: "input",
  164. itemType: "text",
  165. label: proxy.t("receive.previousProcess"),
  166. prop: "previousProcessesName",
  167. readonly: true,
  168. },
  169. {
  170. type: "input",
  171. itemType: "text",
  172. label: "流转人",
  173. prop: "circulationUserName",
  174. readonly: true,
  175. },
  176. ]);
  177. const onClickLeft = () => history.back();
  178. const onSubmit = () => {
  179. proxy
  180. .post("/productionTaskDetail/haveTaskCount", {
  181. productionProcessesId: formData.data.productionProcessesId,
  182. })
  183. .then((res) => {
  184. if (res.data && Number(res.data) > 0) {
  185. showConfirmDialog({
  186. title: "提示",
  187. message: "你当前还有进行中的任务尚未提交,确认接收新任务吗?",
  188. })
  189. .then(() => {
  190. showConfirmDialog({
  191. title: "提示",
  192. message: "你当前还有进行中的任务尚未提交,确认接收新任务吗?",
  193. })
  194. .then(() => {
  195. submitApi();
  196. })
  197. .catch(() => {
  198. return;
  199. });
  200. })
  201. .catch(() => {
  202. return;
  203. });
  204. } else {
  205. submitApi();
  206. }
  207. });
  208. };
  209. const submitApi = () => {
  210. proxy.post("/productionTaskDetail/receive", { id: formData.data.id }).then(
  211. (res) => {
  212. setTimeout(() => {
  213. showSuccessToast(proxy.t("common.operationSuccessful"));
  214. proxy.$router.push("/main/jxskReceive");
  215. }, 500);
  216. },
  217. (err) => {
  218. return showFailToast(err.message);
  219. }
  220. );
  221. };
  222. const otherBtnClick = () => {
  223. proxy.post("/productionTaskDetail/rejection", { id: formData.data.id }).then(
  224. (res) => {
  225. setTimeout(() => {
  226. showSuccessToast(proxy.t("common.operationSuccessful"));
  227. proxy.$router.push("/main/jxskReceive");
  228. }, 500);
  229. },
  230. (err) => {
  231. return showFailToast(err.message);
  232. }
  233. );
  234. };
  235. const getDetails = () => {
  236. proxy.post("/productionTaskDetail/detail", { id: route.query.id }).then(
  237. (res) => {
  238. if (
  239. res.data.productionTaskDetailRecordList &&
  240. res.data.productionTaskDetailRecordList.length > 0
  241. ) {
  242. let id = res.data.previousProcessesRecordId;
  243. proxy
  244. .post("/fileInfo/getList", { businessIdList: [id] })
  245. .then((res) => {
  246. if (res.data[id] && res.data[id].length > 0) {
  247. formData.data.fileList = res.data[id].map((item) => {
  248. return {
  249. raw: item,
  250. name: item.fileName,
  251. url: item.fileUrl,
  252. };
  253. });
  254. }
  255. });
  256. }
  257. proxy
  258. .post("/fileInfo/getList", {
  259. businessIdList: [res.data.productionProcessesId],
  260. })
  261. .then((resOne) => {
  262. if (
  263. resOne.data[res.data.productionProcessesId] &&
  264. resOne.data[res.data.productionProcessesId].length > 0
  265. ) {
  266. formData.data.fileListTwo = resOne.data[
  267. res.data.productionProcessesId
  268. ].map((item) => {
  269. return {
  270. raw: item,
  271. name: item.fileName,
  272. url: item.fileUrl,
  273. };
  274. });
  275. }
  276. });
  277. proxy
  278. .post("/fileInfo/getList", {
  279. businessIdList: [res.data.workOrderId],
  280. fileType: 1,
  281. })
  282. .then((resOne) => {
  283. if (
  284. resOne.data[res.data.workOrderId] &&
  285. resOne.data[res.data.workOrderId].length > 0
  286. ) {
  287. formData.data.fileListThree = resOne.data[res.data.workOrderId].map(
  288. (item) => {
  289. return {
  290. raw: item,
  291. name: item.fileName,
  292. url: item.fileUrl,
  293. };
  294. }
  295. );
  296. }
  297. });
  298. },
  299. (err) => {
  300. return showFailToast(err.message);
  301. }
  302. );
  303. };
  304. onMounted(() => {
  305. if (route.query.id) {
  306. formData.data = { ...route.query };
  307. getDetails();
  308. if (
  309. !formData.data.previousProcessesId ||
  310. formData.data.previousProcessesId == -1
  311. ) {
  312. formOption.otherBtn = false;
  313. }
  314. }
  315. });
  316. const onPreviewFile = (item) => {
  317. uni.postMessage({
  318. data: {
  319. type: "file",
  320. url: item.url,
  321. name: item.name,
  322. },
  323. });
  324. };
  325. </script>
  326. <style lang="scss" scoped>
  327. .row {
  328. display: flex;
  329. padding: 5px 10px 0 10px;
  330. justify-content: space-between;
  331. align-items: center;
  332. .title {
  333. flex: 1;
  334. }
  335. .delete {
  336. width: 20px;
  337. cursor: pointer;
  338. text-align: center;
  339. }
  340. }
  341. </style>