index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <template>
  2. <div class="pageIndexClass">
  3. <div>
  4. <byTable :source="sourceList.data" :pagination="sourceList.pagination" :config="config" :loading="loading" highlight-current-row
  5. :selectConfig="selectConfig" :action-list="[
  6. {
  7. text: '添加专利',
  8. action: () => openModal('add'),
  9. disabled: false,
  10. },
  11. ]" @get-list="getList">
  12. <template #name="{ item }">
  13. <div>
  14. <span class="el-click">{{ item.name }}</span>
  15. </div>
  16. </template>
  17. </byTable>
  18. </div>
  19. <el-dialog :title="modalType == 'add' ? '添加专利' : '编辑专利'" v-model="dialogVisible" width="500px" destroy-on-close>
  20. <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="formDom" v-loading="submitLoading">
  21. </byForm>
  22. <template #footer>
  23. <el-button @click="dialogVisible = false" size="defualt" v-debounce>取 消</el-button>
  24. <el-button type="primary" @click="submitForm()" size="defualt" v-debounce :loading="submitLoading">
  25. 确 定
  26. </el-button>
  27. </template>
  28. </el-dialog>
  29. </div>
  30. </template>
  31. <script setup>
  32. import byTable from "@/components/byTable/index";
  33. import byForm from "@/components/byForm/index";
  34. const { proxy } = getCurrentInstance();
  35. const loading = ref(false);
  36. const submitLoading = ref(false);
  37. const sourceList = ref({
  38. data: [],
  39. pagination: {
  40. total: 3,
  41. pageNum: 1,
  42. pageSize: 10,
  43. keyword: "",
  44. },
  45. });
  46. const treeData = ref([]);
  47. const dialogVisible = ref(false);
  48. const modalType = ref("add");
  49. const selectConfig = computed(() => []);
  50. const config = computed(() => {
  51. return [
  52. {
  53. attrs: {
  54. label: "业务公司",
  55. prop: "companyName",
  56. },
  57. },
  58. {
  59. attrs: {
  60. label: "专利编号",
  61. prop: "code",
  62. },
  63. },
  64. {
  65. attrs: {
  66. label: "专利名称",
  67. prop: "name",
  68. },
  69. },
  70. // {
  71. // attrs: {
  72. // label: "开户行",
  73. // prop: "accountBank",
  74. // },
  75. // },
  76. // {
  77. // attrs: {
  78. // label: "开户名",
  79. // prop: "accountName",
  80. // },
  81. // },
  82. // {
  83. // attrs: {
  84. // label: "账号",
  85. // prop: "accountNumber",
  86. // },
  87. // },
  88. {
  89. attrs: {
  90. label: "操作",
  91. width: "120",
  92. align: "center",
  93. fixed: "right",
  94. },
  95. renderHTML(row) {
  96. return [
  97. {
  98. attrs: {
  99. label: "修改",
  100. type: "primary",
  101. text: true,
  102. },
  103. el: "button",
  104. click() {
  105. getDtl(row);
  106. },
  107. },
  108. {
  109. attrs: {
  110. label: "删除",
  111. type: "danger",
  112. text: true,
  113. },
  114. el: "button",
  115. click() {
  116. proxy
  117. .msgConfirm()
  118. .then((res) => {
  119. proxy
  120. .post("/patent/delete", {
  121. id: row.id,
  122. })
  123. .then((res) => {
  124. proxy.msgTip("删除成功", 1);
  125. getList();
  126. });
  127. })
  128. .catch((err) => {});
  129. },
  130. },
  131. ];
  132. },
  133. },
  134. ];
  135. });
  136. const formData = reactive({
  137. data: {},
  138. });
  139. const formOption = reactive({
  140. inline: true,
  141. labelWidth: 100,
  142. itemWidth: 100,
  143. });
  144. const formDom = ref(null);
  145. const formConfig = computed(() => {
  146. return [
  147. {
  148. type: "treeSelect",
  149. prop: "companyId",
  150. label: "业务公司",
  151. data: treeData.value,
  152. propsTreeLabel: "deptName",
  153. propsTreeValue: "deptId",
  154. itemWidth: 100,
  155. disabled: false,
  156. },
  157. {
  158. type: "input",
  159. prop: "name",
  160. label: "专利名称",
  161. itemWidth: 100,
  162. disabled: false,
  163. },
  164. {
  165. type: "input",
  166. prop: "code",
  167. label: "专利号",
  168. itemWidth: 100,
  169. disabled: false,
  170. },
  171. // {
  172. // type: "input",
  173. // prop: "accountBank",
  174. // label: "开户行",
  175. // placeholder: "请输入开户行",
  176. // itemWidth: 100,
  177. // },
  178. // {
  179. // type: "input",
  180. // prop: "accountName",
  181. // label: "开户名",
  182. // placeholder: "请输入开户名",
  183. // itemWidth: 100,
  184. // },
  185. // {
  186. // type: "input",
  187. // prop: "accountNumber",
  188. // label: "账号",
  189. // placeholder: "请输入账号",
  190. // itemWidth: 100,
  191. // },
  192. {
  193. type: "input",
  194. prop: "jdSubjectCode",
  195. label: "金蝶编号",
  196. },
  197. {
  198. type: "input",
  199. prop: "jdSubjectName",
  200. label: "金蝶名称",
  201. },
  202. ];
  203. });
  204. const rules = ref({
  205. companyId: [{ required: true, message: "请选择业务公司", trigger: "change" }],
  206. name: [{ required: true, message: "请输入专利名称", trigger: "blur" }],
  207. code: [{ required: true, message: "请输入专利编号", trigger: "blur" }],
  208. });
  209. const getDeptData = () => {
  210. proxy
  211. .get("/tenantDept/list", {
  212. pageNum: 1,
  213. pageSize: 9999,
  214. keyword: "",
  215. tenantId: proxy.useUserStore().user.tenantId,
  216. type: 0,
  217. })
  218. .then((res) => {
  219. treeData.value = proxy.handleTree(res.data, "deptId");
  220. });
  221. };
  222. getDeptData();
  223. const getList = async (req) => {
  224. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  225. loading.value = true;
  226. proxy.post("/patent/page", sourceList.value.pagination).then((res) => {
  227. sourceList.value.data = res.rows;
  228. sourceList.value.pagination.total = res.total;
  229. setTimeout(() => {
  230. loading.value = false;
  231. }, 200);
  232. });
  233. };
  234. const openModal = () => {
  235. dialogVisible.value = true;
  236. modalType.value = "add";
  237. formData.data = {
  238. definition: "2",
  239. fileList: [],
  240. };
  241. };
  242. const submitForm = () => {
  243. formDom.value.handleSubmit((valid) => {
  244. submitLoading.value = true;
  245. proxy.post("/patent/" + modalType.value, formData.data).then(
  246. (res) => {
  247. proxy.msgTip("操作成功", 1);
  248. dialogVisible.value = false;
  249. submitLoading.value = false;
  250. getList();
  251. },
  252. (err) => {
  253. submitLoading.value = false;
  254. }
  255. );
  256. });
  257. };
  258. const getDtl = (row) => {
  259. modalType.value = "edit";
  260. proxy.post("/patent/detail", { id: row.id }).then((res) => {
  261. formData.data = res;
  262. dialogVisible.value = true;
  263. });
  264. };
  265. getList();
  266. </script>
  267. <style lang="scss" scoped>
  268. .content {
  269. padding: 20px;
  270. }
  271. </style>