index.vue 13 KB

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