index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <template>
  2. <div class="p-2">
  3. <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
  4. <div v-show="showSearch" class="mb-[10px]">
  5. <el-card shadow="hover">
  6. <el-form ref="queryFormRef" :model="queryParams" :inline="true">
  7. <el-form-item label="定制编号" prop="customizationNo">
  8. <el-input v-model="queryParams.customizationNo" placeholder="请输入定制编号" clearable @keyup.enter="handleQuery" />
  9. </el-form-item>
  10. <el-form-item label="产品id" prop="productId">
  11. <el-input v-model="queryParams.productId" placeholder="请输入产品id" clearable @keyup.enter="handleQuery" />
  12. </el-form-item>
  13. <el-form-item label="定制方式 支持多选,分隔 (0=包装定制,1=商品定制,2=开模定制)" prop="customizedStyle">
  14. <el-input v-model="queryParams.customizedStyle" placeholder="请输入定制方式 支持多选,分隔 (0=包装定制,1=商品定制,2=开模定制)" clearable @keyup.enter="handleQuery" />
  15. </el-form-item>
  16. <el-form-item label="定制工艺 支持多选,分隔 (0=丝印,1=热转印,2=激光,烤花,压印)" prop="customizedCraft">
  17. <el-input v-model="queryParams.customizedCraft" placeholder="请输入定制工艺 支持多选,分隔 (0=丝印,1=热转印,2=激光,烤花,压印)" clearable @keyup.enter="handleQuery" />
  18. </el-form-item>
  19. <el-form-item label="打样周期" prop="proofingPeriod">
  20. <el-input v-model="queryParams.proofingPeriod" placeholder="请输入打样周期" clearable @keyup.enter="handleQuery" />
  21. </el-form-item>
  22. <el-form-item label="生产周期" prop="productionCycle">
  23. <el-input v-model="queryParams.productionCycle" placeholder="请输入生产周期" clearable @keyup.enter="handleQuery" />
  24. </el-form-item>
  25. <el-form-item label="最小起订量" prop="moq">
  26. <el-input v-model="queryParams.moq" placeholder="请输入最小起订量" clearable @keyup.enter="handleQuery" />
  27. </el-form-item>
  28. <el-form-item label="MOQ对应价格" prop="moqPrice">
  29. <el-input v-model="queryParams.moqPrice" placeholder="请输入MOQ对应价格" clearable @keyup.enter="handleQuery" />
  30. </el-form-item>
  31. <el-form-item label="平台标识" prop="platformCode">
  32. <el-input v-model="queryParams.platformCode" placeholder="请输入平台标识" clearable @keyup.enter="handleQuery" />
  33. </el-form-item>
  34. <el-form-item>
  35. <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
  36. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  37. </el-form-item>
  38. </el-form>
  39. </el-card>
  40. </div>
  41. </transition>
  42. <el-card shadow="never">
  43. <template #header>
  44. <el-row :gutter="10" class="mb8">
  45. <el-col :span="1.5">
  46. <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['product:customization:add']">新增</el-button>
  47. </el-col>
  48. <el-col :span="1.5">
  49. <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['product:customization:edit']">修改</el-button>
  50. </el-col>
  51. <el-col :span="1.5">
  52. <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['product:customization:remove']">删除</el-button>
  53. </el-col>
  54. <el-col :span="1.5">
  55. <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['product:customization:export']">导出</el-button>
  56. </el-col>
  57. <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
  58. </el-row>
  59. </template>
  60. <el-table v-loading="loading" border :data="customizationList" @selection-change="handleSelectionChange">
  61. <el-table-column type="selection" width="55" align="center" />
  62. <el-table-column label="主键ID" align="center" prop="id" v-if="true" />
  63. <el-table-column label="定制编号" align="center" prop="customizationNo" />
  64. <el-table-column label="产品id" align="center" prop="productId" />
  65. <el-table-column label="定制方式 支持多选,分隔 (0=包装定制,1=商品定制,2=开模定制)" align="center" prop="customizedStyle" />
  66. <el-table-column label="定制工艺 支持多选,分隔 (0=丝印,1=热转印,2=激光,烤花,压印)" align="center" prop="customizedCraft" />
  67. <el-table-column label="打样周期" align="center" prop="proofingPeriod" />
  68. <el-table-column label="生产周期" align="center" prop="productionCycle" />
  69. <el-table-column label="最小起订量" align="center" prop="moq" />
  70. <el-table-column label="MOQ对应价格" align="center" prop="moqPrice" />
  71. <el-table-column label="备注" align="center" prop="remark" />
  72. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  73. <template #default="scope">
  74. <el-tooltip content="修改" placement="top">
  75. <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['product:customization:edit']"></el-button>
  76. </el-tooltip>
  77. <el-tooltip content="删除" placement="top">
  78. <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['product:customization:remove']"></el-button>
  79. </el-tooltip>
  80. </template>
  81. </el-table-column>
  82. </el-table>
  83. <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
  84. </el-card>
  85. <!-- 添加或修改产品定制信息对话框 -->
  86. <el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
  87. <el-form ref="customizationFormRef" :model="form" :rules="rules" label-width="80px">
  88. <el-form-item label="定制编号" prop="customizationNo">
  89. <el-input v-model="form.customizationNo" placeholder="请输入定制编号" />
  90. </el-form-item>
  91. <el-form-item label="产品id" prop="productId">
  92. <el-input v-model="form.productId" placeholder="请输入产品id" />
  93. </el-form-item>
  94. <el-form-item label="定制方式 支持多选,分隔 (0=包装定制,1=商品定制,2=开模定制)" prop="customizedStyle">
  95. <el-input v-model="form.customizedStyle" placeholder="请输入定制方式 支持多选,分隔 (0=包装定制,1=商品定制,2=开模定制)" />
  96. </el-form-item>
  97. <el-form-item label="定制工艺 支持多选,分隔 (0=丝印,1=热转印,2=激光,烤花,压印)" prop="customizedCraft">
  98. <el-input v-model="form.customizedCraft" placeholder="请输入定制工艺 支持多选,分隔 (0=丝印,1=热转印,2=激光,烤花,压印)" />
  99. </el-form-item>
  100. <el-form-item label="打样周期" prop="proofingPeriod">
  101. <el-input v-model="form.proofingPeriod" placeholder="请输入打样周期" />
  102. </el-form-item>
  103. <el-form-item label="生产周期" prop="productionCycle">
  104. <el-input v-model="form.productionCycle" placeholder="请输入生产周期" />
  105. </el-form-item>
  106. <el-form-item label="最小起订量" prop="moq">
  107. <el-input v-model="form.moq" placeholder="请输入最小起订量" />
  108. </el-form-item>
  109. <el-form-item label="MOQ对应价格" prop="moqPrice">
  110. <el-input v-model="form.moqPrice" placeholder="请输入MOQ对应价格" />
  111. </el-form-item>
  112. <el-form-item label="备注" prop="remark">
  113. <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
  114. </el-form-item>
  115. </el-form>
  116. <template #footer>
  117. <div class="dialog-footer">
  118. <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
  119. <el-button @click="cancel">取 消</el-button>
  120. </div>
  121. </template>
  122. </el-dialog>
  123. </div>
  124. </template>
  125. <script setup name="Customization" lang="ts">
  126. import { listCustomization, getCustomization, delCustomization, addCustomization, updateCustomization } from '@/api/pmsProduct/customization';
  127. import { CustomizationVO, CustomizationQuery, CustomizationForm } from '@/api/pmsProduct/customization/types';
  128. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  129. const customizationList = ref<CustomizationVO[]>([]);
  130. const buttonLoading = ref(false);
  131. const loading = ref(true);
  132. const showSearch = ref(true);
  133. const ids = ref<Array<string | number>>([]);
  134. const single = ref(true);
  135. const multiple = ref(true);
  136. const total = ref(0);
  137. const queryFormRef = ref<ElFormInstance>();
  138. const customizationFormRef = ref<ElFormInstance>();
  139. const dialog = reactive<DialogOption>({
  140. visible: false,
  141. title: ''
  142. });
  143. const initFormData: CustomizationForm = {
  144. id: undefined,
  145. customizationNo: undefined,
  146. productId: undefined,
  147. customizedStyle: undefined,
  148. customizedCraft: undefined,
  149. proofingPeriod: undefined,
  150. productionCycle: undefined,
  151. moq: undefined,
  152. moqPrice: undefined,
  153. remark: undefined,
  154. }
  155. const data = reactive<PageData<CustomizationForm, CustomizationQuery>>({
  156. form: {...initFormData},
  157. queryParams: {
  158. pageNum: 1,
  159. pageSize: 10,
  160. customizationNo: undefined,
  161. productId: undefined,
  162. customizedStyle: undefined,
  163. customizedCraft: undefined,
  164. proofingPeriod: undefined,
  165. productionCycle: undefined,
  166. moq: undefined,
  167. moqPrice: undefined,
  168. platformCode: undefined,
  169. params: {
  170. }
  171. },
  172. rules: {
  173. customizationNo: [
  174. { required: true, message: "定制编号不能为空", trigger: "blur" }
  175. ],
  176. productId: [
  177. { required: true, message: "产品id不能为空", trigger: "blur" }
  178. ],
  179. customizedStyle: [
  180. { required: true, message: "定制方式 支持多选,分隔 (0=包装定制,1=商品定制,2=开模定制)不能为空", trigger: "blur" }
  181. ],
  182. customizedCraft: [
  183. { required: true, message: "定制工艺 支持多选,分隔 (0=丝印,1=热转印,2=激光,烤花,压印)不能为空", trigger: "blur" }
  184. ],
  185. proofingPeriod: [
  186. { required: true, message: "打样周期不能为空", trigger: "blur" }
  187. ],
  188. productionCycle: [
  189. { required: true, message: "生产周期不能为空", trigger: "blur" }
  190. ],
  191. moq: [
  192. { required: true, message: "最小起订量不能为空", trigger: "blur" }
  193. ],
  194. moqPrice: [
  195. { required: true, message: "MOQ对应价格不能为空", trigger: "blur" }
  196. ],
  197. remark: [
  198. { required: true, message: "备注不能为空", trigger: "blur" }
  199. ],
  200. }
  201. });
  202. const { queryParams, form, rules } = toRefs(data);
  203. /** 查询产品定制信息列表 */
  204. const getList = async () => {
  205. loading.value = true;
  206. const res = await listCustomization(queryParams.value);
  207. customizationList.value = res.rows;
  208. total.value = res.total;
  209. loading.value = false;
  210. }
  211. /** 取消按钮 */
  212. const cancel = () => {
  213. reset();
  214. dialog.visible = false;
  215. }
  216. /** 表单重置 */
  217. const reset = () => {
  218. form.value = {...initFormData};
  219. customizationFormRef.value?.resetFields();
  220. }
  221. /** 搜索按钮操作 */
  222. const handleQuery = () => {
  223. queryParams.value.pageNum = 1;
  224. getList();
  225. }
  226. /** 重置按钮操作 */
  227. const resetQuery = () => {
  228. queryFormRef.value?.resetFields();
  229. handleQuery();
  230. }
  231. /** 多选框选中数据 */
  232. const handleSelectionChange = (selection: CustomizationVO[]) => {
  233. ids.value = selection.map(item => item.id);
  234. single.value = selection.length != 1;
  235. multiple.value = !selection.length;
  236. }
  237. /** 新增按钮操作 */
  238. const handleAdd = () => {
  239. reset();
  240. dialog.visible = true;
  241. dialog.title = "添加产品定制信息";
  242. }
  243. /** 修改按钮操作 */
  244. const handleUpdate = async (row?: CustomizationVO) => {
  245. reset();
  246. const _id = row?.id || ids.value[0]
  247. const res = await getCustomization(_id);
  248. Object.assign(form.value, res.data);
  249. dialog.visible = true;
  250. dialog.title = "修改产品定制信息";
  251. }
  252. /** 提交按钮 */
  253. const submitForm = () => {
  254. customizationFormRef.value?.validate(async (valid: boolean) => {
  255. if (valid) {
  256. buttonLoading.value = true;
  257. if (form.value.id) {
  258. await updateCustomization(form.value).finally(() => buttonLoading.value = false);
  259. } else {
  260. await addCustomization(form.value).finally(() => buttonLoading.value = false);
  261. }
  262. proxy?.$modal.msgSuccess("操作成功");
  263. dialog.visible = false;
  264. await getList();
  265. }
  266. });
  267. }
  268. /** 删除按钮操作 */
  269. const handleDelete = async (row?: CustomizationVO) => {
  270. const _ids = row?.id || ids.value;
  271. await proxy?.$modal.confirm('是否确认删除产品定制信息编号为"' + _ids + '"的数据项?').finally(() => loading.value = false);
  272. await delCustomization(_ids);
  273. proxy?.$modal.msgSuccess("删除成功");
  274. await getList();
  275. }
  276. /** 导出按钮操作 */
  277. const handleExport = () => {
  278. proxy?.download('product/customization/export', {
  279. ...queryParams.value
  280. }, `customization_${new Date().getTime()}.xlsx`)
  281. }
  282. onMounted(() => {
  283. getList();
  284. });
  285. </script>