You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

350 lines
11 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <div style="display: flex">
  3. <el-table
  4. :data="personnelUnit.personnelgrouping"
  5. style="width: 100%"
  6. row-key="id"
  7. highlight-current-row
  8. @row-click="clickoncolumn"
  9. class="el-table__body-wrapper tbody"
  10. >
  11. <el-table-column type="index" label="序号" width=""> </el-table-column>
  12. <el-table-column prop="displayName" label="名称" width="">
  13. </el-table-column>
  14. <el-table-column prop="creatorName" label="创建者"> </el-table-column>
  15. <el-table-column prop="" label="创建时间">
  16. <template slot-scope="scope">
  17. {{ scope.row.creationTime | dateFormat }}
  18. </template>
  19. </el-table-column>
  20. <el-table-column prop="forSexId" label="性别"> </el-table-column>
  21. <el-table-column prop="maritalStatusId" label="婚姻状况">
  22. </el-table-column>
  23. <el-table-column prop="price" label="价格"> </el-table-column>
  24. <el-table-column label="操作">
  25. <template>
  26. <el-tag
  27. class="move"
  28. style="cursor: move; margin-left: 15px"
  29. draggable="true"
  30. >
  31. <i class="el-icon-d-caret" style="width: 1rem; height: 1rem"></i>
  32. </el-tag>
  33. </template>
  34. </el-table-column>
  35. </el-table>
  36. <div style="margin-top: 3%; margin-left: 10px">
  37. <div style="margin-left: 10px; margin-top: 5%">
  38. <div style="margin-top: 10px">
  39. <el-button type="primary" @click="groupaddtion">新增</el-button>
  40. </div>
  41. <div style="margin-top: 10px">
  42. <el-button type="success" @click="editgroup">编辑</el-button>
  43. </div>
  44. <div style="margin-top: 10px">
  45. <el-button type="danger" @click="deletegroup">删除</el-button>
  46. </div>
  47. <div style="margin-top: 10px">
  48. <el-button type="primary" @click="topping">置顶</el-button>
  49. </div>
  50. <div style="margin-top: 10px">
  51. <el-button type="primary" @click="bottoming">置低</el-button>
  52. </div>
  53. <div style="margin-top: 10px">
  54. <el-button type="primary" @click="sortok" :disabled="isshow"
  55. >确定</el-button
  56. >
  57. </div>
  58. </div>
  59. </div>
  60. <!-- 新增或者编辑弹框 -->
  61. <el-dialog
  62. :title="title == '1' ? '新增' : '编辑'"
  63. :visible.sync="dialogVisible"
  64. width="50%"
  65. >
  66. <el-form :model="form" label-width="80px">
  67. <el-row>
  68. <el-col :span="8">
  69. <el-form-item label="分组名称">
  70. <el-input v-model="form.displayName"></el-input>
  71. </el-form-item>
  72. </el-col>
  73. <el-col :span="8">
  74. <el-form-item label="价格">
  75. <el-input v-model="form.price"></el-input>
  76. </el-form-item>
  77. </el-col>
  78. <el-col :span="8">
  79. <el-form-item label="适用性别">
  80. <el-select v-model="form.forSexId" placeholder="请选择">
  81. <el-option
  82. v-for="item in forSexId"
  83. :key="item.id"
  84. :label="item.displayName"
  85. :value="item.id"
  86. >
  87. </el-option>
  88. </el-select>
  89. </el-form-item>
  90. </el-col>
  91. <el-col :span="8">
  92. <el-form-item label="婚姻状况">
  93. <el-select v-model="form.maritalStatusId" placeholder="请选择">
  94. <el-option
  95. v-for="item in maritalStatusId"
  96. :key="item.id"
  97. :label="item.displayName"
  98. :value="item.id"
  99. >
  100. </el-option>
  101. </el-select>
  102. </el-form-item>
  103. </el-col>
  104. <el-col :span="8">
  105. <el-form-item label="年龄下限">
  106. <el-input v-model="form.ageLowerLimit"></el-input>
  107. </el-form-item>
  108. </el-col>
  109. <el-col :span="8">
  110. <el-form-item label="年龄上限">
  111. <el-input v-model="form.ageUpperLimit"></el-input>
  112. </el-form-item>
  113. </el-col>
  114. <el-col :span="8">
  115. <el-form-item label="适用职务">
  116. <el-input v-model="form.jobPost"></el-input>
  117. </el-form-item>
  118. </el-col>
  119. <el-col :span="8">
  120. <el-form-item label="适用职称">
  121. <el-input v-model="form.jobTitle"></el-input>
  122. </el-form-item>
  123. </el-col>
  124. <el-col :span="8">
  125. <el-form-item label="备注">
  126. <el-input v-model="form.remark"></el-input>
  127. </el-form-item>
  128. </el-col>
  129. </el-row>
  130. </el-form>
  131. <span slot="footer" class="dialog-footer">
  132. <el-button @click="dialogVisible = false"> </el-button>
  133. <el-button type="primary" @click="Onsubmint"> </el-button>
  134. </span>
  135. </el-dialog>
  136. <!-- -->
  137. </div>
  138. </template>
  139. <script>
  140. import Sortable from "sortablejs";
  141. import { getapi, postapi, putapi, deletapi } from "@/api/api";
  142. import { mapState } from "vuex";
  143. export default {
  144. data() {
  145. return {
  146. isshow: true,
  147. title: 1,
  148. form: {
  149. displayName: "",
  150. price: "",
  151. forSexId: "",
  152. maritalStatusId: "",
  153. ageLowerLimit: "",
  154. ageUpperLimit: "",
  155. jobPost: "",
  156. jobTitle: "",
  157. remark: "",
  158. },
  159. forSexId: [], //性别id
  160. maritalStatusId: [], //婚姻状况
  161. dialogVisible: false,
  162. tableData: [],
  163. initTableData: [],
  164. // tableData: [
  165. // ],
  166. };
  167. },
  168. computed: {
  169. ...mapState(["personnelUnit"]),
  170. },
  171. created() {
  172. this.rowDrop();
  173. },
  174. mounted() {
  175. //console.log('00000',this.personnelUnit.id);
  176. },
  177. methods: {
  178. //确定排序
  179. sortok() {
  180. const result = [];
  181. this.tableData.forEach((item, index) => {
  182. // index 从0开始的, 你的displayOrder从大到小排
  183. console.log(item.id);
  184. // const currentDisplayOrder = this.tableData.length -1
  185. const currentDisplayOrder = this.initTableData[index].displayOrder;
  186. if (item.displayOrder != currentDisplayOrder) {
  187. // 如果它的displayOrder和它当前所在的位置不同代表挪动过位置
  188. result.push({ id: item.id, displayOrder: currentDisplayOrder });
  189. }
  190. });
  191. putapi("/api/app/customerorggroup/updatesortmany", {
  192. itemList: result,
  193. }).then((res) => {
  194. this.$message.success("操作成功");
  195. this.isshow = true;
  196. this.getlist();
  197. });
  198. },
  199. //初始化Sortable组件
  200. rowDrop() {
  201. this.$nextTick(() => {
  202. const tbody = document.querySelector(".el-table__body-wrapper tbody");
  203. const _this = this;
  204. Sortable.create(tbody, {
  205. handle: ".move",
  206. animation: 300,
  207. onEnd({ newIndex, oldIndex }) {
  208. _this.isshow = false;
  209. const currRow = _this.tableData.splice(oldIndex, 1)[0];
  210. _this.tableData.splice(newIndex, 0, currRow);
  211. _this.tableData.map((item, index) => {
  212. if (index == newIndex && index == oldIndex) {
  213. } else if (index == oldIndex) {
  214. } else if (index == newIndex) {
  215. }
  216. });
  217. console.log(_this.tableData.map((item) => item.displayOrder));
  218. },
  219. });
  220. });
  221. },
  222. getlist() {
  223. getapi(
  224. `/api/app/customer-org-group/in-customer-org-id/${this.personnelUnit.id}`
  225. ).then((res) => {
  226. this.tableData = res.data;
  227. this.personnelUnit.personnelgrouping = res.data;
  228. this.initTableData = [...res.data];
  229. });
  230. },
  231. //置低
  232. bottoming() {
  233. if (this.form.id == undefined) {
  234. this.$message.warning("请选择操作的数据");
  235. } else {
  236. putapi(
  237. `/api/app/customerorggroup/updatemanysort?id=${this.form.id}&SortType=2`
  238. ).then((res) => {
  239. this.$message.success("操作成功");
  240. this.getlist();
  241. });
  242. }
  243. },
  244. //置顶
  245. topping() {
  246. if (this.form.id == undefined) {
  247. this.$message.warning("请选择操作的数据");
  248. } else {
  249. putapi(
  250. `/api/app/customerorggroup/updatemanysort?id=${this.form.id}&SortType=1`
  251. ).then((res) => {
  252. this.$message.success("操作成功");
  253. this.getlist();
  254. });
  255. }
  256. },
  257. //删除
  258. deletegroup() {
  259. if (this.form.id == undefined) {
  260. this.$message.warning("请选择需要操作的数据");
  261. } else {
  262. deletapi(`/api/app/customer-org-group/${this.form.id}`).then((res) => {
  263. this.$message.success("删除成功");
  264. });
  265. }
  266. },
  267. //点击当前列
  268. clickoncolumn(row) {
  269. getapi(`/api/app/customer-org-group/${row.id}`).then((res) => {
  270. this.form = res.data;
  271. });
  272. //获取已选组合项目列表
  273. getapi(`/api/app/customer-org-group-detail/customer-org-group-detail-in-asbitem?CustomerOrgGroupId=${this.form.id}`).then(res=>{
  274. console.log(res,'ssssss');
  275. })
  276. },
  277. //编辑弹框
  278. editgroup() {
  279. this.title = 2;
  280. this.obtainsuperior();
  281. this.dialogVisible = true;
  282. },
  283. //获取性别和婚姻状况
  284. obtainsuperior() {
  285. //获取性别
  286. getapi("/api/app/sex").then((res) => {
  287. this.forSexId = res.data;
  288. });
  289. //获取婚姻状况
  290. getapi("/api/app/marital-statuses").then((res) => {
  291. this.maritalStatusId = res.data.items;
  292. console.log(res);
  293. });
  294. },
  295. Onsubmint() {
  296. if (this.title == 1) {
  297. let obj = {
  298. displayName: this.form.displayName,
  299. price: Number(this.form.price),
  300. forSexId: this.form.forSexId,
  301. maritalStatusId: this.form.maritalStatusId,
  302. ageLowerLimit: Number(this.form.ageLowerLimit),
  303. ageUpperLimit: Number(this.form.ageUpperLimit),
  304. jobPost: this.form.jobPost,
  305. jobTitle: this.form.jobTitle,
  306. remark: this.form.remark,
  307. };
  308. postapi(
  309. `/api/app/customer-org-group/in-customer-org-id/${this.personnelUnit.id}`,
  310. obj
  311. ).then((res) => {
  312. this.$message.success("新增成功");
  313. this.dialogVisible = false;
  314. });
  315. } else if (this.title == 2) {
  316. let obj = {
  317. displayName: this.form.displayName,
  318. price: Number(this.form.price),
  319. forSexId: this.form.forSexId,
  320. maritalStatusId: this.form.maritalStatusId,
  321. ageLowerLimit: Number(this.form.ageLowerLimit),
  322. ageUpperLimit: Number(this.form.ageUpperLimit),
  323. jobPost: this.form.jobPost,
  324. jobTitle: this.form.jobTitle,
  325. remark: this.form.remark,
  326. };
  327. putapi(`/api/app/customer-org-group/${this.form.id}`, obj).then(
  328. (res) => {
  329. this.$message.success("修改成功");
  330. this.dialogVisible = false;
  331. }
  332. );
  333. }
  334. },
  335. //新增弹框
  336. groupaddtion() {
  337. if (this.personnelUnit.id == "") {
  338. this.$message.warning("请选择单位");
  339. } else {
  340. this.dialogVisible = true;
  341. this.title = 1;
  342. this.obtainsuperior();
  343. }
  344. },
  345. },
  346. };
  347. </script>