index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item>
  5. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  6. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  7. </el-form-item>
  8. </el-form>
  9. <el-row :gutter="10" class="mb8">
  10. <el-col :span="1.5">
  11. <el-button
  12. type="primary"
  13. plain
  14. icon="el-icon-plus"
  15. size="mini"
  16. @click="handleAdd"
  17. >新增
  18. </el-button>
  19. </el-col>
  20. <el-col :span="1.5">
  21. <el-button
  22. type="success"
  23. plain
  24. icon="el-icon-edit"
  25. size="mini"
  26. :disabled="single"
  27. @click="handleUpdate"
  28. >修改
  29. </el-button>
  30. </el-col>
  31. <el-col :span="1.5">
  32. <el-button
  33. type="danger"
  34. plain
  35. icon="el-icon-delete"
  36. size="mini"
  37. :disabled="multiple"
  38. @click="handleDelete"
  39. >删除
  40. </el-button>
  41. </el-col>
  42. <el-col :span="1.5">
  43. <el-button
  44. type="warning"
  45. plain
  46. icon="el-icon-download"
  47. size="mini"
  48. @click="handleExport"
  49. >导出
  50. </el-button>
  51. </el-col>
  52. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  53. </el-row>
  54. <el-table v-loading="loading" :data="lifeCycleList" @selection-change="handleSelectionChange">
  55. <el-table-column type="selection" width="55" align="center"/>
  56. <!-- <el-table-column label="主键" align="center" prop="id"/>-->
  57. <el-table-column label="创建人" align="center" prop="createBy"/>
  58. <el-table-column label="创建时间" align="center" prop="createTime" width="180">
  59. <template slot-scope="scope">
  60. <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
  61. </template>
  62. </el-table-column>
  63. <el-table-column label="事项" align="center" prop="matter"/>
  64. <el-table-column label="操作人" align="center" prop="operator"/>
  65. <el-table-column label="时间" align="center" prop="time" width="180">
  66. <template slot-scope="scope">
  67. <span>{{ parseTime(scope.row.time, '{y}-{m}-{d}') }}</span>
  68. </template>
  69. </el-table-column>
  70. <el-table-column label="类型" align="center" prop="type">
  71. <template slot-scope="scope">
  72. <dict-tag :options="dict.type.life_cycle_type" :value="scope.row.type"/>
  73. </template>
  74. </el-table-column>
  75. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  76. <template slot-scope="scope">
  77. <el-button
  78. size="mini"
  79. type="text"
  80. icon="el-icon-edit"
  81. @click="handleUpdate(scope.row)"
  82. >修改
  83. </el-button>
  84. <el-button
  85. size="mini"
  86. type="text"
  87. icon="el-icon-delete"
  88. @click="handleDelete(scope.row)"
  89. >删除
  90. </el-button>
  91. </template>
  92. </el-table-column>
  93. </el-table>
  94. <pagination
  95. v-show="total>0"
  96. :total="total"
  97. :page.sync="queryParams.pageNum"
  98. :limit.sync="queryParams.pageSize"
  99. @pagination="getList"
  100. />
  101. <!-- 添加或修改生命周期对话框 -->
  102. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  103. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  104. <el-form-item label="事项" prop="matter">
  105. <el-input v-model="form.matter" placeholder="请输入事项"/>
  106. </el-form-item>
  107. <el-form-item label="操作人" prop="operator">
  108. <el-input v-model="form.operator" placeholder="请输入操作人"/>
  109. </el-form-item>
  110. <el-form-item label="时间" prop="time">
  111. <el-date-picker clearable
  112. v-model="form.time"
  113. type="date"
  114. value-format="yyyy-MM-dd"
  115. placeholder="请选择时间">
  116. </el-date-picker>
  117. </el-form-item>
  118. <el-form-item label="类型" prop="type">
  119. <el-select v-model="form.type" placeholder="请选择类型">
  120. <el-option
  121. v-for="dict in dict.type.life_cycle_type"
  122. :key="dict.value"
  123. :label="dict.label"
  124. :value="dict.value"
  125. ></el-option>
  126. </el-select>
  127. </el-form-item>
  128. <el-form-item label="请选择物料" prop="skuId">
  129. <el-select placeholder="请选择物料">
  130. <el-option
  131. v-for="sku in materialSkuList"
  132. :key="sku.id"
  133. :label="sku.skuTitle"
  134. :value="sku.id"
  135. ></el-option>
  136. </el-select>
  137. </el-form-item>
  138. </el-form>
  139. <div slot="footer" class="dialog-footer">
  140. <el-button type="primary" @click="submitForm">确 定</el-button>
  141. <el-button @click="cancel">取 消</el-button>
  142. </div>
  143. </el-dialog>
  144. </div>
  145. </template>
  146. <script>
  147. import {
  148. listLifeCycle,
  149. getLifeCycle,
  150. delLifeCycle,
  151. addLifeCycle,
  152. updateLifeCycle,
  153. queryMaterialSku
  154. } from "@/api/omsOrder/lifeCycle";
  155. export default {
  156. name: "LifeCycle",
  157. dicts: ['life_cycle_type'],
  158. data() {
  159. return {
  160. // 遮罩层
  161. loading: true,
  162. // 选中数组
  163. ids: [],
  164. // 非单个禁用
  165. single: true,
  166. // 非多个禁用
  167. multiple: true,
  168. // 显示搜索条件
  169. showSearch: true,
  170. // 总条数
  171. total: 0,
  172. // 生命周期表格数据
  173. lifeCycleList: [],
  174. materialSkuList: [],
  175. // 弹出层标题
  176. title: "",
  177. // 是否显示弹出层
  178. open: false,
  179. // 查询参数
  180. queryParams: {
  181. pageNum: 1,
  182. pageSize: 10,
  183. },
  184. // 表单参数
  185. form: {},
  186. // 表单校验
  187. rules: {}
  188. };
  189. },
  190. created() {
  191. this.getList();
  192. this.queryMaterialSkuList();
  193. },
  194. methods: {
  195. queryMaterialSkuList() {
  196. queryMaterialSku(this.queryParams).then(response => {
  197. this.materialSkuList = response.data;
  198. });
  199. },
  200. /** 查询生命周期列表 */
  201. getList() {
  202. this.loading = true;
  203. listLifeCycle(this.queryParams).then(response => {
  204. this.lifeCycleList = response.rows;
  205. this.total = response.total;
  206. this.loading = false;
  207. });
  208. },
  209. // 取消按钮
  210. cancel() {
  211. this.open = false;
  212. this.reset();
  213. },
  214. // 表单重置
  215. reset() {
  216. this.form = {
  217. id: null,
  218. tenantId: null,
  219. createBy: null,
  220. createTime: null,
  221. updateBy: null,
  222. updateTime: null,
  223. deleteBy: null,
  224. deleteTime: null,
  225. isDeleted: null,
  226. extData: null,
  227. version: null,
  228. matter: null,
  229. operator: null,
  230. time: null,
  231. type: null,
  232. skuId: null
  233. };
  234. this.resetForm("form");
  235. },
  236. /** 搜索按钮操作 */
  237. handleQuery() {
  238. this.queryParams.pageNum = 1;
  239. this.getList();
  240. },
  241. /** 重置按钮操作 */
  242. resetQuery() {
  243. this.resetForm("queryForm");
  244. this.handleQuery();
  245. },
  246. // 多选框选中数据
  247. handleSelectionChange(selection) {
  248. this.ids = selection.map(item => item.id)
  249. this.single = selection.length !== 1
  250. this.multiple = !selection.length
  251. },
  252. /** 新增按钮操作 */
  253. handleAdd() {
  254. this.reset();
  255. this.open = true;
  256. this.title = "添加生命周期";
  257. },
  258. /** 修改按钮操作 */
  259. handleUpdate(row) {
  260. this.reset();
  261. const id = row.id || this.ids
  262. getLifeCycle(id).then(response => {
  263. this.form = response.data;
  264. this.open = true;
  265. this.title = "修改生命周期";
  266. });
  267. },
  268. /** 提交按钮 */
  269. submitForm() {
  270. this.$refs["form"].validate(valid => {
  271. if (valid) {
  272. if (this.form.id != null) {
  273. updateLifeCycle(this.form).then(response => {
  274. this.$modal.msgSuccess("修改成功");
  275. this.open = false;
  276. this.getList();
  277. });
  278. } else {
  279. addLifeCycle(this.form).then(response => {
  280. this.$modal.msgSuccess("新增成功");
  281. this.open = false;
  282. this.getList();
  283. });
  284. }
  285. }
  286. });
  287. },
  288. /** 删除按钮操作 */
  289. handleDelete(row) {
  290. const ids = row.id || this.ids;
  291. this.$modal.confirm('是否确认删除生命周期编号为"' + ids + '"的数据项?').then(function () {
  292. return delLifeCycle(ids);
  293. }).then(() => {
  294. this.getList();
  295. this.$modal.msgSuccess("删除成功");
  296. }).catch(() => {
  297. });
  298. },
  299. /** 导出按钮操作 */
  300. handleExport() {
  301. this.download('omsOrder/lifeCycle/export', {
  302. ...this.queryParams
  303. }, `lifeCycle_${new Date().getTime()}.xlsx`)
  304. }
  305. }
  306. };
  307. </script>