index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. <template>
  2. <div class="tenant">
  3. <!-- <Banner /> -->
  4. <div class="content">
  5. <byTable
  6. :source="sourceList.data"
  7. :pagination="sourceList.pagination"
  8. :config="config"
  9. :loading="loading"
  10. highlight-current-row
  11. :selectConfig="selectConfig"
  12. :table-events="{
  13. //element talbe事件都能传
  14. select: selectRow,
  15. }"
  16. :action-list="[
  17. {
  18. text: '采购',
  19. disabled: selectData.length === 0,
  20. action: () => start(20),
  21. },
  22. ]"
  23. @get-list="getList"
  24. >
  25. <template #fileSlot="{ item }">
  26. <div
  27. style="cursor: pointer; color: #409eff"
  28. @click="handleClickFile(item)"
  29. >
  30. {{ item.fileName }}
  31. </div>
  32. </template>
  33. </byTable>
  34. </div>
  35. <el-dialog
  36. :title="modalType == 'add' ? '添加供应商' : '编辑供应商'"
  37. v-model="dialogVisible"
  38. width="800"
  39. v-loading="loading"
  40. >
  41. <byForm
  42. :formConfig="formConfig"
  43. :formOption="formOption"
  44. v-model="formData.data"
  45. :rules="rules"
  46. ref="byform"
  47. >
  48. <template #address>
  49. <el-row :gutter="10" style="width: 100%">
  50. <el-col :span="8">
  51. <el-select v-model="formData.data.aa" placeholder="国家">
  52. <el-option v-for="item in 3" label="ceshi" value="1">
  53. </el-option>
  54. </el-select>
  55. </el-col>
  56. <el-col :span="8">
  57. <el-select v-model="formData.data.aa" placeholder="省/洲">
  58. <el-option v-for="item in 3" label="ceshi" value="1">
  59. </el-option>
  60. </el-select>
  61. </el-col>
  62. <el-col :span="8">
  63. <el-select v-model="formData.data.aa" placeholder="城市">
  64. <el-option v-for="item in 3" label="ceshi" value="1">
  65. </el-option>
  66. </el-select>
  67. </el-col>
  68. </el-row>
  69. <el-row style="margin-top: 20px; width: 100%">
  70. <el-col :span="24">
  71. <el-input v-model="formData.data.bb" type="textarea"> </el-input>
  72. </el-col>
  73. </el-row>
  74. </template>
  75. <template #contact>
  76. <el-row :gutter="10" style="width: 100%">
  77. <el-col :span="8">
  78. <el-input v-model="formData.data.aa" placeholder="联系人">
  79. </el-input>
  80. </el-col>
  81. <el-col :span="16">
  82. <el-input v-model="formData.data.aa" placeholder="联系电话">
  83. </el-input>
  84. </el-col>
  85. </el-row>
  86. </template>
  87. <template #fileSlot>
  88. <div>
  89. <el-upload
  90. v-model:fileList="fileList"
  91. class="upload-demo"
  92. action="https://winfaster.obs.cn-south-1.myhuaweicloud.com"
  93. :limit="3"
  94. :data="uploadData"
  95. :on-preview="handlePreview"
  96. :on-remove="handleRemove"
  97. :on-success="handleSuccess"
  98. :before-upload="handleBeforeUpload"
  99. accept=".pdf"
  100. >
  101. <el-button type="primary">选择</el-button>
  102. <template #file>
  103. <div>
  104. <div style="margin-top: 15px">
  105. <el-tag
  106. class="ml-2"
  107. type="info"
  108. v-for="(item, index) in fileList"
  109. :key="index"
  110. closable
  111. @close="handleClose(index)"
  112. >{{ item.fileName }}</el-tag
  113. >
  114. </div>
  115. </div>
  116. </template>
  117. </el-upload>
  118. </div>
  119. </template>
  120. </byForm>
  121. <template #footer>
  122. <el-button @click="dialogVisible = false" size="large">取 消</el-button>
  123. <el-button
  124. type="primary"
  125. @click="submitForm('byform')"
  126. size="large"
  127. :loading="submitLoading"
  128. >
  129. 确 定
  130. </el-button>
  131. </template>
  132. </el-dialog>
  133. </div>
  134. </template>
  135. <script setup>
  136. /* eslint-disable vue/no-unused-components */
  137. import { ElMessage, ElMessageBox } from "element-plus";
  138. import byTable from "@/components/byTable/index";
  139. import byForm from "@/components/byForm/index";
  140. import FileUpload from "@/components/FileUpload/index";
  141. import { computed, defineComponent, ref } from "vue";
  142. import { getToken } from "@/utils/auth";
  143. const uploadFileUrl = ref(import.meta.env.VITE_APP_BASE_API + "/common/upload"); // 上传文件服务器地址
  144. const headers = ref({ Authorization: "Bearer " + getToken() });
  145. const uploadData = ref({});
  146. const loading = ref(false);
  147. const submitLoading = ref(false);
  148. const sourceList = ref({
  149. data: [],
  150. pagination: {
  151. total: 3,
  152. pageNum: 1,
  153. pageSize: 10,
  154. status: "15",
  155. },
  156. });
  157. let dialogVisible = ref(false);
  158. let modalType = ref("add");
  159. let fileList = ref([]);
  160. let rules = ref({
  161. name: [{ required: true, message: "请输入供应商名称", trigger: "blur" }],
  162. });
  163. const { proxy } = getCurrentInstance();
  164. const selectConfig = reactive([
  165. {
  166. label: "状态",
  167. prop: "status",
  168. data: [
  169. {
  170. label: "待采购",
  171. value: "15",
  172. },
  173. {
  174. label: "部分采购",
  175. value: "30",
  176. },
  177. ],
  178. },
  179. {
  180. label: "收获仓库",
  181. prop: "receiptWarehouseId",
  182. data: [],
  183. },
  184. ]);
  185. const config = computed(() => {
  186. return [
  187. {
  188. type: "selection",
  189. attrs: {
  190. checkAtt: "isCheck",
  191. },
  192. },
  193. {
  194. attrs: {
  195. label: "申购单号",
  196. prop: "subscribeCode",
  197. },
  198. },
  199. {
  200. attrs: {
  201. label: "货品类型",
  202. prop: "definition",
  203. },
  204. render(definition) {
  205. return definition == 1 ? "产品" : definition == 1 ? "物料" : "";
  206. },
  207. },
  208. {
  209. attrs: {
  210. label: "物品编码",
  211. prop: "productCode",
  212. },
  213. },
  214. {
  215. attrs: {
  216. label: "物品名称",
  217. prop: "productName",
  218. },
  219. },
  220. {
  221. attrs: {
  222. label: "单位",
  223. prop: "productUnit",
  224. },
  225. },
  226. {
  227. attrs: {
  228. label: "申购数量",
  229. prop: "count",
  230. },
  231. },
  232. {
  233. attrs: {
  234. label: "已采购数量",
  235. prop: "purchaseCount",
  236. },
  237. },
  238. {
  239. attrs: {
  240. label: "收货仓库",
  241. prop: "receiptWarehouseName",
  242. width: 130,
  243. },
  244. },
  245. {
  246. attrs: {
  247. label: "要求到货时间",
  248. prop: "planArrivalTime",
  249. width: 130,
  250. },
  251. },
  252. {
  253. attrs: {
  254. label: "采购状态",
  255. prop: "status",
  256. },
  257. render(status) {
  258. return status == 15 ? "待采购" : "部分采购";
  259. },
  260. },
  261. {
  262. attrs: {
  263. label: "申购人",
  264. prop: "subcribeName",
  265. },
  266. },
  267. {
  268. attrs: {
  269. label: "申购时间",
  270. prop: "subcribeTime",
  271. width: 155,
  272. },
  273. },
  274. {
  275. attrs: {
  276. label: "操作",
  277. width: "80",
  278. align: "right",
  279. },
  280. // 渲染 el-button,一般用在最后一列。
  281. renderHTML(row) {
  282. return [
  283. {
  284. attrs: {
  285. label: "采购",
  286. type: "primary",
  287. text: true,
  288. },
  289. el: "button",
  290. click() {
  291. selectDataOne.value = [row];
  292. start(10);
  293. },
  294. },
  295. ];
  296. },
  297. },
  298. ];
  299. });
  300. let formData = reactive({
  301. data: {
  302. type: "1",
  303. },
  304. });
  305. const formOption = reactive({
  306. inline: true,
  307. labelWidth: 100,
  308. itemWidth: 100,
  309. rules: [],
  310. });
  311. const byform = ref(null);
  312. const formConfig = computed(() => {
  313. return [
  314. {
  315. type: "radio",
  316. prop: "name",
  317. label: "供应商类型",
  318. required: true,
  319. border: true,
  320. data: [
  321. { label: "贸易商", value: "1" },
  322. { label: "工厂", value: "2" },
  323. ],
  324. },
  325. {
  326. type: "input",
  327. prop: "name",
  328. label: "供应商名称",
  329. required: true,
  330. },
  331. {
  332. type: "slot",
  333. slotName: "address",
  334. label: "地址",
  335. required: true,
  336. },
  337. {
  338. type: "slot",
  339. slotName: "contact",
  340. label: "联系信息",
  341. required: true,
  342. },
  343. {
  344. type: "slot",
  345. slotName: "fileSlot",
  346. label: "上传附件",
  347. },
  348. {
  349. type: "input",
  350. label: "备注",
  351. prop: "remakes",
  352. itemType: "textarea",
  353. },
  354. ];
  355. });
  356. const getList = async (req) => {
  357. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  358. loading.value = true;
  359. proxy
  360. .post("/subscribeDetail/pageByWdly", sourceList.value.pagination)
  361. .then((message) => {
  362. console.log(message);
  363. message.rows.forEach((x) => {
  364. if (x.status <= 30) {
  365. x.isCheck = true;
  366. } else {
  367. x.isCheck = false;
  368. }
  369. });
  370. sourceList.value.data = message.rows.map((x) => ({
  371. ...x,
  372. ...JSON.parse(x.victoriatouristJson),
  373. }));
  374. sourceList.value.pagination.total = message.total;
  375. setTimeout(() => {
  376. loading.value = false;
  377. }, 200);
  378. });
  379. };
  380. // const openModal = () => {
  381. // proxy.$router.push({
  382. // })
  383. // };
  384. const submitForm = () => {
  385. if (fileList.value.length > 0) {
  386. byform.value.handleSubmit((valid) => {
  387. formData.data.fileList = fileList.value;
  388. submitLoading.value = true;
  389. proxy.post("/productionProcesses/" + modalType.value, formData.data).then(
  390. (res) => {
  391. ElMessage({
  392. message: modalType.value == "add" ? "添加成功" : "编辑成功",
  393. type: "success",
  394. });
  395. fileList.value = [];
  396. dialogVisible.value = false;
  397. submitLoading.value = false;
  398. getList();
  399. },
  400. (err) => {
  401. console.log(err, "aswwwww");
  402. submitLoading.value = false;
  403. }
  404. );
  405. });
  406. } else {
  407. return ElMessage({
  408. message: "请上传附件!",
  409. type: "info",
  410. });
  411. }
  412. };
  413. const getDtl = (row) => {
  414. modalType.value = "edit";
  415. proxy.post("/productionProcesses/detail", { id: row.id }).then((res) => {
  416. fileList.value = [
  417. {
  418. id: "",
  419. fileName: res.fileName,
  420. path: "",
  421. },
  422. ];
  423. formData.data = res;
  424. dialogVisible.value = true;
  425. });
  426. };
  427. const handleBeforeUpload = async (file) => {
  428. const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
  429. uploadData.value = res.uploadBody;
  430. fileList.value = [
  431. {
  432. id: res.id,
  433. fileName: res.fileName,
  434. path: res.fileUrl,
  435. },
  436. ];
  437. };
  438. const handlePreview = (file) => {
  439. console.log(file);
  440. };
  441. const handleSuccess = (file) => {
  442. console.log(file);
  443. };
  444. const handleRemove = (file) => {
  445. fileList.value = [];
  446. };
  447. const handleClose = (index) => {
  448. fileList.value.splice(index, 1);
  449. };
  450. getList();
  451. const selectData = ref([]);
  452. const selectDataOne = ref([]);
  453. const selectRow = (data) => {
  454. selectData.value = data;
  455. };
  456. watch(selectData, (newVal, oldVal) => {
  457. if (newVal.length == 0) {
  458. sourceList.value.data.forEach((x) => {
  459. if (x.status <= 30) {
  460. x.isCheck = true;
  461. } else {
  462. x.isCheck = false;
  463. }
  464. });
  465. } else if (newVal.length == 1) {
  466. const current = newVal[0];
  467. sourceList.value.data.forEach((x) => {
  468. if (x.receiptWarehouseId !== current.receiptWarehouseId) {
  469. x.isCheck = false;
  470. }
  471. });
  472. }
  473. });
  474. const start = (type) => {
  475. modalType.value = "add";
  476. let ids = [];
  477. let row = {};
  478. if (type === 10) {
  479. row = selectDataOne.value[0];
  480. ids = selectDataOne.value.map((x) => x.id).join();
  481. } else if (type === 20) {
  482. ids = selectData.value.map((x) => x.id).join();
  483. row = selectData.value[0];
  484. }
  485. proxy.$router.replace({
  486. path: "/platform_manage/process/processApproval",
  487. query: {
  488. flowKey: "wdly_purchase",
  489. ids,
  490. flowName: "采购申请",
  491. },
  492. });
  493. };
  494. const warehouseList = ref([]);
  495. const warehouseListData = () => {
  496. // // 币种数据
  497. proxy
  498. .post("/warehouse/page", {
  499. pageNum: 1,
  500. pageSize: 999,
  501. })
  502. .then((message) => {
  503. warehouseList.value = message.rows;
  504. selectConfig[1].data = message.rows.map((x) => ({
  505. label: x.name,
  506. value: x.id,
  507. }));
  508. });
  509. };
  510. warehouseListData();
  511. </script>
  512. <style lang="scss" scoped>
  513. .tenant {
  514. padding: 20px;
  515. }
  516. :deep(.el-table__header-wrapper .el-checkbox) {
  517. display: none;
  518. }
  519. </style>