project.code-snippets 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. {
  2. "vueinit": {
  3. "prefix": "vueinit",
  4. "body": [
  5. "<template>",
  6. " <div> </div>",
  7. "</template>",
  8. "",
  9. "<script setup></script>",
  10. "",
  11. "<style lang=\"\"></style>"
  12. ],
  13. "description": "vueinit"
  14. },
  15. "List page": {
  16. "prefix": "lp",
  17. "body": [
  18. "<template>",
  19. " <div class=\"p-10\">",
  20. " <a-card :title=\"route.meta.title\">",
  21. " <template #extra>",
  22. " <a-button type=\"primary\" @click=\"eidtModal.show()\">",
  23. " <template #icon> <icon-plus /> </template>创建",
  24. " </a-button>",
  25. " </template>",
  26. "",
  27. " <div class=\"pb-10\">",
  28. " <a-form layout=\"inline\" :model=\"searchParam\">",
  29. " <a-form-item",
  30. " field=\"name\"",
  31. " label=\"名称\"",
  32. " validate-trigger=\"blur\"",
  33. " :rules=\"[]\"",
  34. " >",
  35. " <a-input v-model=\"searchParam.name\" />",
  36. " </a-form-item>",
  37. "",
  38. " <a-form-item>",
  39. " <a-space>",
  40. " <a-button type=\"primary\" @click=\"search\">查询</a-button>",
  41. " <a-button @click=\"reset\">重置</a-button>",
  42. " </a-space>",
  43. " </a-form-item>",
  44. " </a-form>",
  45. " </div>",
  46. "",
  47. " <a-table",
  48. " :loading=\"loading\"",
  49. " :data=\"tableData\"",
  50. " :pagination=\"pagination\"",
  51. " @pageChange=\"handleCurrentChange\"",
  52. " @pageSizeChange=\"handleSizeChange\"",
  53. " >",
  54. " <template #columns>",
  55. " <a-table-column",
  56. " v-for=\"(col, index) in columns\"",
  57. " :key=\"index\"",
  58. " v-bind=\"col\"",
  59. " >",
  60. " <template",
  61. " #cell=\"{ record }\"",
  62. " v-if=\"col.dataIndex.indexOf('Time') > -1\"",
  63. " >",
  64. " {{ dayjs(record[col.dataIndex]).format('YYYY-MM-DD HH:mm:ss') }}",
  65. " </template>",
  66. " </a-table-column>",
  67. "",
  68. " <a-table-column",
  69. " title=\"操作\"",
  70. " data-index=\"actions\"",
  71. " fixed=\"right\"",
  72. " :width=\"200\"",
  73. " >",
  74. " <template #cell=\"{ record }\">",
  75. " <a-space>",
  76. " <a-button",
  77. " size=\"small\"",
  78. " type=\"outline\"",
  79. " @click=\"eidtModal.show(record)\"",
  80. " >",
  81. " 编辑",
  82. " </a-button>",
  83. "",
  84. " <a-button",
  85. " size=\"small\"",
  86. " type=\"outline\"",
  87. " status=\"danger\"",
  88. " @click=\"handleDelete(record.id)\"",
  89. " >",
  90. " 删除",
  91. " </a-button>",
  92. " </a-space>",
  93. " </template>",
  94. " </a-table-column>",
  95. " </template>",
  96. " </a-table>",
  97. " </a-card>",
  98. "",
  99. " <EidtModal ref=\"eidtModal\" @update=\"getTableList\"></EidtModal>",
  100. " </div>",
  101. "</template>",
  102. "",
  103. "<script setup>",
  104. " import { useTable } from '@/hooks/useTable';",
  105. " import { meterialApi as api } from '@/api/material';",
  106. "",
  107. " import EidtModal from './Modal.vue';",
  108. " import { Modal } from '@arco-design/web-vue';",
  109. " import dayjs from 'dayjs';",
  110. "",
  111. " const route = useRoute();",
  112. " const eidtModal = ref();",
  113. "",
  114. " const initParam = reactive({",
  115. " name: '',",
  116. " });",
  117. "",
  118. " const columns = [",
  119. " { title: '名称', dataIndex: 'name', fixed: 'left' },",
  120. " { title: '名称', dataIndex: 'name' },",
  121. " ];",
  122. "",
  123. " const {",
  124. " loading,",
  125. " tableData,",
  126. " pagination,",
  127. " searchParam,",
  128. " search,",
  129. " getTableList,",
  130. " reset,",
  131. " handleSizeChange,",
  132. " handleCurrentChange,",
  133. " } = useTable({",
  134. " api: api.getList,",
  135. " initParam,",
  136. " showPage: true,",
  137. " });",
  138. "",
  139. " const handleDelete = (id) => {",
  140. " Modal.confirm({",
  141. " title: '提示',",
  142. " content: `确定删除吗?`,",
  143. " onOk: async () => {",
  144. " await api.deleteItem(id);",
  145. "",
  146. " getTableList();",
  147. " },",
  148. " });",
  149. " };",
  150. "</script>",
  151. "",
  152. "<style lang=\"\"></style>"
  153. ],
  154. "description": "Modal page"
  155. },
  156. "Modal page": {
  157. "prefix": "mp",
  158. "body": [
  159. "<template>",
  160. " <a-modal",
  161. " :title=\"title\"",
  162. " v-model:visible=\"visible\"",
  163. " @cancel=\"hide\"",
  164. " @before-ok=\"handleSubmit\"",
  165. " unmount-on-close",
  166. " >",
  167. " <a-form",
  168. " ref=\"formRef\"",
  169. " auto-label-width",
  170. " class=\"max-w-[80%] px-5 mx-auto\"",
  171. " layout=\"horizontal\"",
  172. " :model=\"form\"",
  173. " >",
  174. " <a-form-item",
  175. " field=\"name\"",
  176. " label=\"名称\"",
  177. " :rules=\"[{ required: true, message: '请输入' }]\"",
  178. " >",
  179. " <a-input v-model=\"form.name\"></a-input>",
  180. " </a-form-item>",
  181. " </a-form>",
  182. " </a-modal>",
  183. "</template>",
  184. "",
  185. "<script setup>",
  186. " import useModal from '@/hooks/useModal';",
  187. " import { api } from '@/api/${1}';",
  188. "",
  189. " const emit = defineEmits(['update']);",
  190. "",
  191. " const route = useRoute();",
  192. " const title = computed(() => {",
  193. " return (editType.value === 'add' ? '新增' : '编辑') + route.meta.title;",
  194. " });",
  195. "",
  196. " const { visible, editType, form, show, hide, formRef, handleSubmit } =",
  197. " useModal({",
  198. " emit,",
  199. " add: api.addItem,",
  200. " update: api.updateItem,",
  201. " defaultForm: {",
  202. " name: '',",
  203. " seq: '',",
  204. " description: '',",
  205. " },",
  206. " });",
  207. "",
  208. " defineExpose({",
  209. " show,",
  210. " });",
  211. "</script>"
  212. ],
  213. "description": "Modal page"
  214. },
  215. "form-submit": {
  216. "prefix": "form-submit",
  217. "body": [
  218. "const formRef = ref(null);",
  219. "const handleSubmit = async (done) => {",
  220. " const res = await formRef.value?.validate();",
  221. "",
  222. " if (res) return;",
  223. "};"
  224. ],
  225. "description": "form-submit"
  226. },
  227. "form-validate": {
  228. "prefix": "form-validate",
  229. "body": [
  230. "const res = await formRef.value?.validate();",
  231. " ",
  232. "if (res) return;"
  233. ],
  234. "description": "form-validate"
  235. },
  236. "use-modal": {
  237. "prefix": "use-modal",
  238. "body": [
  239. "import useModal from '@/hooks/useModal';",
  240. "import { add, update} from '';",
  241. "const emit = defineEmits(['update']);",
  242. "const { visible, editType, form, show, hide, formRef, handleSubmit } =",
  243. " useModal({",
  244. " emit,",
  245. " add,",
  246. " update,",
  247. " defaultForm: {",
  248. " name: '',",
  249. " nick_name: '',",
  250. " deptId: '',",
  251. " },",
  252. " });",
  253. "",
  254. " defineExpose({",
  255. " show,",
  256. " });"
  257. ],
  258. "description": "use-modal"
  259. },
  260. "form switch": {
  261. "prefix": "form-switch",
  262. "body": [
  263. "<a-form-item field=\"${1}\" label=\"${2}\" :rules=\"[]\">",
  264. " <a-switch v-model=\"form.${1}\"></a-switch>",
  265. "</a-form-item>"
  266. ],
  267. "description": "form switch"
  268. },
  269. "form radio map": {
  270. "prefix": "form-radio-map",
  271. "body": [
  272. "<a-form-item",
  273. " field=\"${1}\"",
  274. " label=\"${2}\"",
  275. " :rules=\"[{ required: true, message: '请输入' }]\"",
  276. ">",
  277. " <a-radio-group v-model=\"form.${1}\">",
  278. " <a-radio",
  279. " v-for=\"[key,item] in ${3}\"",
  280. " :key=\"key\"",
  281. " :value=\"key\"",
  282. " >",
  283. " {{ item }}",
  284. " </a-radio>",
  285. " </a-radio-group>",
  286. "</a-form-item>"
  287. ],
  288. "description": "form radio map"
  289. },
  290. "form radio array": {
  291. "prefix": "form-radio-array",
  292. "body": [
  293. "<a-form-item",
  294. " field=\"${1}\"",
  295. " label=\"${2}\"",
  296. " :rules=\"[{ required: true, message: '请输入' }]\"",
  297. ">",
  298. " <a-radio-group v-model=\"form.${1}\">",
  299. " <a-radio",
  300. " v-for=\"(item, index) in ${3}\"",
  301. " :key=\"index\"",
  302. " :value=\"index\"",
  303. " >",
  304. " {{ item }}",
  305. " </a-radio>",
  306. " </a-radio-group>",
  307. "</a-form-item>"
  308. ],
  309. "description": "form radio array"
  310. },
  311. "form select array": {
  312. "prefix": "form-select-array",
  313. "body": [
  314. "<a-form-item",
  315. " field=\"${1}\"",
  316. " label=\"${2}\"",
  317. " :rules=\"[{ required: true, message: '请输入' }]\"",
  318. ">",
  319. " <a-select v-model=\"form.${1}\" placeholder=\"请选择\">",
  320. " <a-option",
  321. " v-for=\"(item,index) in ${3}\"",
  322. " :key=\"index\"",
  323. " :value=\"\"",
  324. " >",
  325. " {{ item }}",
  326. " </a-option>",
  327. " </a-select>",
  328. "</a-form-item>"
  329. ],
  330. "description": "form select array"
  331. },
  332. "form select map": {
  333. "prefix": "form-select-map",
  334. "body": [
  335. "<a-form-item",
  336. " field=\"${1}\"",
  337. " label=\"${2}\"",
  338. " :rules=\"[{ required: true, message: '请输入' }]\"",
  339. ">",
  340. " <a-select v-model=\"form.${1}\" placeholder=\"请选择\">",
  341. " <a-option",
  342. " v-for=\"[key, item] in ${3}\"",
  343. " :key=\"key\"",
  344. " :value=\"key\"",
  345. " >",
  346. " {{ item }}",
  347. " </a-option>",
  348. " </a-select>",
  349. "</a-form-item>"
  350. ],
  351. "description": "form select map"
  352. },
  353. "form textarea": {
  354. "prefix": "form-textarea",
  355. "body": [
  356. "<a-form-item field=\"${1}\" label=\"${2}\" :rules=\"[{ required: true, message: '请输入' }]\">",
  357. " <a-textarea v-model=\"form.${1}\"></a-textarea>",
  358. "</a-form-item>"
  359. ],
  360. "description": "form textarea"
  361. },
  362. "form number": {
  363. "prefix": "form-number",
  364. "body": [
  365. "<a-form-item field=\"${1}\" label=\"${2}\" :rules=\"[{ required: true, message: '请输入' }]\">",
  366. " <a-input-number v-model=\"form.${1}\"></a-input-number>",
  367. "</a-form-item>"
  368. ],
  369. "description": "form number"
  370. },
  371. "form input": {
  372. "prefix": "form-input",
  373. "body": [
  374. "<a-form-item field=\"${1}\" label=\"${2}\" :rules=\"[{ required: true, message: '请输入' }]\">",
  375. " <a-input v-model=\"form.${1}\"></a-input>",
  376. "</a-form-item>"
  377. ],
  378. "description": "form input"
  379. }
  380. }