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.

369 lines
12 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
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
  94. v-model="form.maritalStatusId"
  95. placeholder="请选择"
  96. style="width: 100%"
  97. >
  98. <el-option
  99. v-for="item in maritalStatusId"
  100. :key="item.id"
  101. :label="item.displayName"
  102. :value="item.id"
  103. >
  104. </el-option>
  105. </el-select>
  106. </el-form-item>
  107. </el-col>
  108. <el-col :span="8">
  109. <el-form-item label="年龄下限">
  110. <el-input v-model="form.ageLowerLimit"></el-input>
  111. </el-form-item>
  112. </el-col>
  113. <el-col :span="8">
  114. <el-form-item label="年龄上限">
  115. <el-input v-model="form.ageUpperLimit"></el-input>
  116. </el-form-item>
  117. </el-col>
  118. <el-col :span="8">
  119. <el-form-item label="适用职务">
  120. <el-input v-model="form.jobPost"></el-input>
  121. </el-form-item>
  122. </el-col>
  123. <el-col :span="8">
  124. <el-form-item label="适用职称">
  125. <el-input v-model="form.jobTitle"></el-input>
  126. </el-form-item>
  127. </el-col>
  128. <el-col :span="8">
  129. <el-form-item label="备注">
  130. <el-input v-model="form.remark"></el-input>
  131. </el-form-item>
  132. </el-col>
  133. </el-row>
  134. </el-form>
  135. <span slot="footer" class="dialog-footer">
  136. <el-button @click="dialogVisible = false"> </el-button>
  137. <el-button type="primary" @click="Onsubmint"> </el-button>
  138. </span>
  139. </el-dialog>
  140. <!-- -->
  141. </div>
  142. </template>
  143. <script>
  144. import nat from "@/views/customerOrg/customerOrgGroup.vue";
  145. import Sortable from "sortablejs";
  146. import { getapi, postapi, putapi, deletapi } from "@/api/api";
  147. import { mapState } from "vuex";
  148. export default {
  149. data() {
  150. return {
  151. isshow: true,
  152. title: 1,
  153. form: {
  154. displayName: "",
  155. price: "",
  156. forSexId: "",
  157. maritalStatusId: "",
  158. ageLowerLimit: "",
  159. ageUpperLimit: "",
  160. jobPost: "",
  161. jobTitle: "",
  162. remark: "",
  163. },
  164. forSexId: [], //性别id
  165. maritalStatusId: [], //婚姻状况
  166. dialogVisible: false,
  167. tableData: [],
  168. initTableData: [],
  169. // tableData: [
  170. // ],
  171. };
  172. },
  173. computed: {
  174. ...mapState(["personnelUnit"]),
  175. },
  176. created() {
  177. this.rowDrop();
  178. },
  179. mounted() {
  180. //console.log('00000',this.personnelUnit.id);
  181. },
  182. methods: {
  183. //确定排序
  184. sortok() {
  185. const result = [];
  186. this.tableData.forEach((item, index) => {
  187. // index 从0开始的, 你的displayOrder从大到小排
  188. console.log(item.id);
  189. // const currentDisplayOrder = this.tableData.length -1
  190. const currentDisplayOrder = this.initTableData[index].displayOrder;
  191. if (item.displayOrder != currentDisplayOrder) {
  192. // 如果它的displayOrder和它当前所在的位置不同代表挪动过位置
  193. result.push({ id: item.id, displayOrder: currentDisplayOrder });
  194. }
  195. });
  196. putapi("/api/app/customerorggroup/updatesortmany", {
  197. itemList: result,
  198. }).then((res) => {
  199. this.$message.success("操作成功");
  200. this.isshow = true;
  201. this.getlist();
  202. });
  203. },
  204. //初始化Sortable组件
  205. rowDrop() {
  206. this.$nextTick(() => {
  207. const tbody = document.querySelector(".el-table__body-wrapper tbody");
  208. const _this = this;
  209. Sortable.create(tbody, {
  210. handle: ".move",
  211. animation: 300,
  212. onEnd({ newIndex, oldIndex }) {
  213. _this.isshow = false;
  214. const currRow = _this.tableData.splice(oldIndex, 1)[0];
  215. _this.tableData.splice(newIndex, 0, currRow);
  216. _this.tableData.map((item, index) => {
  217. if (index == newIndex && index == oldIndex) {
  218. } else if (index == oldIndex) {
  219. } else if (index == newIndex) {
  220. }
  221. });
  222. console.log(_this.tableData.map((item) => item.displayOrder));
  223. },
  224. });
  225. });
  226. },
  227. getlist() {
  228. getapi(
  229. `/api/app/customer-org-group/in-customer-org-id/${this.personnelUnit.id}`
  230. ).then((res) => {
  231. this.tableData = res.data;
  232. this.personnelUnit.personnelgrouping = res.data;
  233. this.initTableData = [...res.data];
  234. // console.log( this.personnelUnit.personnelgrouping);
  235. });
  236. },
  237. //置低
  238. bottoming() {
  239. if (this.form.id == undefined) {
  240. this.$message.warning("请选择操作的数据");
  241. } else {
  242. putapi(
  243. `/api/app/customerorggroup/updatemanysort?id=${this.form.id}&SortType=2`
  244. ).then((res) => {
  245. this.$message.success("操作成功");
  246. this.getlist();
  247. });
  248. }
  249. },
  250. //置顶
  251. topping() {
  252. if (this.form.id == undefined) {
  253. this.$message.warning("请选择操作的数据");
  254. } else {
  255. putapi(
  256. `/api/app/customerorggroup/updatemanysort?id=${this.form.id}&SortType=1`
  257. ).then((res) => {
  258. this.$message.success("操作成功");
  259. this.getlist();
  260. });
  261. }
  262. },
  263. //删除
  264. deletegroup() {
  265. if (this.form.id == undefined) {
  266. this.$message.warning("请选择需要操作的数据");
  267. } else {
  268. deletapi(`/api/app/customer-org-group/${this.form.id}`).then((res) => {
  269. this.$message.success("删除成功");
  270. });
  271. }
  272. },
  273. //点击当前列
  274. clickoncolumn(row) {
  275. console.log(row.id);
  276. this.personnelUnit.customerOrgGroupId = row.id;
  277. getapi(`/api/app/customer-org-group/${row.id}`).then((res) => {
  278. this.form = res.data;
  279. this.personnelUnit.form = res.data;
  280. });
  281. // //
  282. console.log(this.personnelUnit.form.id);
  283. // getapi(
  284. // `/api/app/customer-org-group-detail/customer-org-group-detail-in-asbitem/${this.personnelUnit.form.id}`
  285. // ).then((res) => {
  286. // console.log(res.data, "当前列");
  287. // this.personnelUnit.nogroupselected = res.data;
  288. // console.log(this.personnelUnit.nogroupselected, "我是分组");
  289. // });
  290. },
  291. //编辑弹框
  292. editgroup() {
  293. this.title = 2;
  294. this.obtainsuperior();
  295. this.dialogVisible = true;
  296. },
  297. //获取性别和婚姻状况
  298. obtainsuperior() {
  299. //获取性别
  300. getapi("/api/app/sex").then((res) => {
  301. this.forSexId = res.data;
  302. });
  303. //获取婚姻状况
  304. getapi("/api/app/marital-statuses").then((res) => {
  305. this.maritalStatusId = res.data.items;
  306. console.log(res);
  307. });
  308. },
  309. Onsubmint() {
  310. if (this.title == 1) {
  311. let obj = {
  312. displayName: this.form.displayName,
  313. price: Number(this.form.price),
  314. forSexId: this.form.forSexId,
  315. maritalStatusId: this.form.maritalStatusId,
  316. ageLowerLimit: Number(this.form.ageLowerLimit),
  317. ageUpperLimit: Number(this.form.ageUpperLimit),
  318. jobPost: this.form.jobPost,
  319. jobTitle: this.form.jobTitle,
  320. remark: this.form.remark,
  321. };
  322. postapi(
  323. `/api/app/customer-org-group/in-customer-org-id/${this.personnelUnit.id}`,
  324. obj
  325. ).then((res) => {
  326. this.$message.success("新增成功");
  327. this.dialogVisible = false;
  328. });
  329. } else if (this.title == 2) {
  330. let obj = {
  331. displayName: this.form.displayName,
  332. price: Number(this.form.price),
  333. forSexId: this.form.forSexId,
  334. maritalStatusId: this.form.maritalStatusId,
  335. ageLowerLimit: Number(this.form.ageLowerLimit),
  336. ageUpperLimit: Number(this.form.ageUpperLimit),
  337. jobPost: this.form.jobPost,
  338. jobTitle: this.form.jobTitle,
  339. remark: this.form.remark,
  340. };
  341. putapi(`/api/app/customer-org-group/${this.form.id}`, obj).then(
  342. (res) => {
  343. this.$message.success("修改成功");
  344. this.dialogVisible = false;
  345. }
  346. );
  347. }
  348. },
  349. //新增弹框
  350. groupaddtion() {
  351. if (this.personnelUnit.id == "") {
  352. this.$message.warning("请选择单位");
  353. } else {
  354. this.dialogVisible = true;
  355. this.title = 1;
  356. this.form = {};
  357. this.obtainsuperior();
  358. }
  359. },
  360. },
  361. };
  362. </script>
  363. <style scoped>
  364. ::v-deep .el-form-item {
  365. margin-bottom: 10px;
  366. }
  367. </style>