index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <div>
  3. <avue-crud
  4. ref="crudRef"
  5. v-model:search="search"
  6. v-model="form"
  7. :data="data"
  8. :option="option"
  9. v-model:page="page"
  10. @row-save="createRow"
  11. @row-update="updateRow"
  12. @row-del="deleteRow"
  13. @search-change="searchChange"
  14. @search-reset="resetChange"
  15. @size-change="dataList"
  16. @current-change="dataList"
  17. @selection-change="selectionChange"
  18. >
  19. <!-- <template #menu-right="{}">
  20. <el-button
  21. class="ml-3"
  22. @click="exportData('/api/v1/plan/order/export')"
  23. >
  24. <template #icon> <i-ep-download /> </template>导出
  25. </el-button>
  26. </template> -->
  27. <template #menu-left="{}">
  28. <el-button
  29. type="primary"
  30. @click="editDialog.visible = true"
  31. style="margin-bottom: 15px"
  32. >编辑</el-button
  33. >
  34. </template>
  35. <template #menu="{ row, index, type }">
  36. <el-button @click="deleteTep(row.id)" text type="primary"
  37. >删除</el-button
  38. >
  39. </template>
  40. </avue-crud>
  41. <el-dialog
  42. v-model="editDialog.visible"
  43. :title="editDialog.title"
  44. width="1200px"
  45. @close="handleClose"
  46. >
  47. <div class="dialog">
  48. <div>
  49. 请选择Excel模板:
  50. <el-select
  51. v-model="value1"
  52. multiple
  53. placeholder="Select"
  54. filterable
  55. style="width: 79%"
  56. >
  57. <el-option
  58. v-for="item in options"
  59. :key="item.value"
  60. :label="item.label"
  61. :value="item.value"
  62. />
  63. </el-select>
  64. </div>
  65. <div class="btns">
  66. <el-button @click="handleClose">取消</el-button>
  67. <el-button type="primary" @click="onSelected"> 确定 </el-button>
  68. </div>
  69. </div>
  70. </el-dialog>
  71. </div>
  72. </template>
  73. <script setup>
  74. import { ref } from "vue";
  75. import { useCrud } from "@/hooks/userCrud";
  76. import { useDictionaryStore } from "@/store";
  77. import { useRoute } from "vue-router";
  78. import { getForm, add, deleteTemp } from "@/api/excel";
  79. const value1 = ref([]);
  80. const options = ref([]);
  81. const route = useRoute();
  82. //删除
  83. const deleteTep = async (id) => {
  84. const { data, code } = await deleteTemp({
  85. id,
  86. });
  87. if (code == "200") {
  88. ElMessage.success("删除成功!");
  89. dataList();
  90. setValue1();
  91. }
  92. };
  93. //新增
  94. const onSelected = async () => {
  95. const { data, code } = await add({
  96. baseFormIds: value1.value,
  97. operationId: route.fullPath.split("/")[4],
  98. });
  99. if (code == "200") {
  100. ElMessage.success("添加成功!");
  101. dataList();
  102. handleClose();
  103. }
  104. };
  105. //关闭弹窗
  106. const handleClose = () => {
  107. editDialog.value.visible = false;
  108. value1.value = [];
  109. };
  110. // 数据字典相关
  111. const { dicts } = useDictionaryStore();
  112. // 传入一个url,后面不带/
  113. const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
  114. useCrud({
  115. src: "/api/v1/opExcelForm",
  116. });
  117. const setValue1 = () => {
  118. value1.value = [];
  119. data.value.forEach((el) => {
  120. value1.value.push(el.formCode);
  121. });
  122. };
  123. search.value = { ...search.value, operationId: route.fullPath.split("/")[4] };
  124. const { dataList, createRow, updateRow, deleteRow, searchChange, resetChange } =
  125. Methords; //增删改查
  126. const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
  127. const { checkBtnPerm, downloadTemplate, exportData } = Utils; //按钮权限等工具
  128. const editDialog = ref({ visible: false, title: "绑定模版" });
  129. const crudRef = ref(null); //crudRef.value 获取avue-crud对象
  130. //获取Excel模版列表
  131. const getTemplate = async () => {
  132. const { data } = await getForm({
  133. pageNo: 1,
  134. pageSize: 9999999,
  135. formType: 0,
  136. state: 2,
  137. });
  138. options.value = [];
  139. data.records.forEach((element) => {
  140. options.value.push({
  141. value: element.id,
  142. label: element.formName,
  143. });
  144. });
  145. };
  146. onMounted(() => {
  147. getTemplate();
  148. dataList();
  149. });
  150. watch(
  151. () => data.value,
  152. (val) => {
  153. setValue1();
  154. },
  155. {
  156. immediately: true,
  157. }
  158. );
  159. option.value = Object.assign(option.value, {
  160. searchEnter: true,
  161. selection: false,
  162. addBtn: false,
  163. menu: true,
  164. viewBtn: false,
  165. editBtn: false,
  166. delBtn: false,
  167. searchMenuSpan: 8,
  168. column: [
  169. {
  170. label: "工序id",
  171. prop: "operationId",
  172. display: false,
  173. hide: true,
  174. },
  175. {
  176. label: "模版名称",
  177. prop: "formName",
  178. addDisabled: true,
  179. editDisabled: true,
  180. },
  181. {
  182. label: "模版类型",
  183. prop: "formType",
  184. addDisabled: true,
  185. editDisabled: true,
  186. dicData: dicts.excel_type,
  187. props: { label: "dictLabel", value: "dictValue" },
  188. },
  189. {
  190. label: "修改时间",
  191. prop: "updated",
  192. addDisabled: true,
  193. editDisabled: true,
  194. },
  195. {
  196. label: "操作人",
  197. prop: "updator",
  198. addDisabled: true,
  199. editDisabled: true,
  200. },
  201. ],
  202. });
  203. </script>
  204. <style lang="scss" scoped>
  205. .dialog {
  206. width: 100%;
  207. height: 120px;
  208. position: relative;
  209. .btns {
  210. position: absolute;
  211. right: 0;
  212. bottom: 0;
  213. }
  214. }
  215. </style>