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.
 
 
 

488 lines
11 KiB

  1. <template>
  2. <div class="box-center">
  3. <!-- 头 -->
  4. <div class="app-top">
  5. <div style="margin-left: 20px; display: flex">
  6. <el-button @click="editorinfo()" type="primary">新增 </el-button>
  7. <div style="margin-left: auto; margin-right: 10px"></div>
  8. </div>
  9. </div>
  10. <!-- 表格 -->
  11. <div class="cen-tab">
  12. <el-table
  13. ref="tableSortable"
  14. :data="tableData"
  15. stripe
  16. style="width: 100%; height: 400px"
  17. row-key="id"
  18. >
  19. <el-table-column label="序号" prop="sort" align="center">
  20. </el-table-column>
  21. <el-table-column
  22. prop="name"
  23. label="无效原因"
  24. align="center"
  25. ></el-table-column>
  26. <el-table-column label="操作" align="center">
  27. <template slot-scope="{ row }" style="">
  28. <el-button type="text" @click="bianji(row)">编辑</el-button>
  29. <el-button type="text" @click="del(row)">删除</el-button>
  30. </template>
  31. </el-table-column>
  32. </el-table>
  33. </div>
  34. <el-dialog
  35. :title="editFlag ? '编辑' : '新增'"
  36. :visible.sync="dialogVisible"
  37. @close="$refs.ruleForm.resetFields()"
  38. >
  39. <el-form
  40. :model="ruleForm"
  41. label-position="labelPosition"
  42. :rules="ruleser"
  43. ref="ruleForm"
  44. label-width="140px"
  45. style="width: 60%; margin: 0 auto"
  46. >
  47. <el-form-item label="无效原因" prop="name">
  48. <el-input v-model="ruleForm.name" maxlength="8" clearable></el-input>
  49. </el-form-item>
  50. </el-form>
  51. <div slot="footer" class="dialog-footer">
  52. <el-button @click="dialogVisible = false">取 消</el-button>
  53. <el-button type="primary" :loading="loadingFlag" @click="addForm"
  54. >保存
  55. </el-button>
  56. </div>
  57. </el-dialog>
  58. <el-dialog
  59. title="删除来源"
  60. :visible.sync="delVisible"
  61. @close="$refs.ruleForm.resetFields()"
  62. >
  63. <div style="text-align: center; margin-bottom: 20px">
  64. 请将此无效的接待转移到以下无效原因中
  65. </div>
  66. <el-form
  67. :model="ruleForm"
  68. label-position="labelPosition"
  69. :rules="ruleser"
  70. ref="ruleForm"
  71. label-width="140px"
  72. style="width: 60%; margin: 0 auto"
  73. >
  74. <el-form-item label="无效接待移至" prop="moveId">
  75. <el-select v-model="deleteParams.moveId" placeholder="请选择">
  76. <el-option
  77. v-for="item in delIdList"
  78. :key="item.value"
  79. :label="item.label"
  80. :value="item.value"
  81. >
  82. </el-option>
  83. </el-select>
  84. </el-form-item>
  85. </el-form>
  86. <div slot="footer" class="dialog-footer">
  87. <el-button
  88. @click="
  89. delVisible = false;
  90. deleteParams.id = '';
  91. "
  92. >取 消</el-button
  93. >
  94. <el-button type="primary" :loading="loadingFlag" @click="deleteItem"
  95. >保存
  96. </el-button>
  97. </div>
  98. </el-dialog>
  99. </div>
  100. </template>
  101. <script>
  102. import Sortable from "sortablejs";
  103. import { Loading } from "element-ui";
  104. export default {
  105. data() {
  106. return {
  107. currentPage4: 1,
  108. value: "",
  109. input: "",
  110. tableData: [],
  111. multipleSelection: [],
  112. dialogVisible: false,
  113. loadingFlag: false,
  114. delVisible: false,
  115. orgType: localStorage.getItem("orgType"),
  116. ruleForm: {
  117. id: "",
  118. name: "", //
  119. houseId: localStorage.getItem("houseId"), // 项目id
  120. },
  121. houseId: "",
  122. houseList: [],
  123. Page: 1,
  124. size: 10,
  125. words: "",
  126. total: 0,
  127. ruleser: {
  128. name: [{ required: true, message: "请填写客户来源", trigger: "blur" }],
  129. },
  130. editFlag: false,
  131. paramsList: {
  132. // 列表入参
  133. id: "",
  134. name: "", // 资源名称
  135. houseId: localStorage.getItem("houseId"), // 项目id
  136. sort: "", // 顺序
  137. },
  138. deleteParams: {
  139. // 删除入参
  140. id: "",
  141. moveId: "",
  142. sort: "", // 序号
  143. houseId: localStorage.getItem("houseId"), // 项目id
  144. },
  145. delIdList: [], // 要转移的数据位置
  146. editParams: {
  147. // 编辑这一项
  148. id: "", //
  149. name: "", //
  150. houseId: localStorage.getItem("houseId"), // 项目id
  151. },
  152. loadingObj: null,
  153. };
  154. },
  155. mounted() {
  156. this.$nextTick(() => {
  157. this.rowDrop();
  158. });
  159. this.getList();
  160. },
  161. methods: {
  162. /*判断类型选择使用方法*/
  163. addForm() {
  164. if (!this.editFlag) this.addCustomer();
  165. else this.editCustomer();
  166. },
  167. // 初始化提交变量
  168. initRuleForm() {
  169. this.ruleForm = {
  170. id: "",
  171. name: "", //
  172. houseId: localStorage.getItem("houseId"), // 项目id
  173. };
  174. },
  175. // 确认添加
  176. addCustomer() {
  177. this.$refs.ruleForm.validate((valid) => {
  178. if (!valid) return;
  179. this.$api.http
  180. .InvalidReceptionAddInvalid({
  181. name: this.ruleForm.name,
  182. houseId: this.paramsList.houseId,
  183. })
  184. .then((res) => {
  185. if (res.code == 10000) {
  186. this.$message({
  187. message: res.message,
  188. type: "success",
  189. });
  190. this.initRuleForm();
  191. this.getList();
  192. } else {
  193. this.$message({
  194. message: res.message,
  195. type: "error",
  196. });
  197. }
  198. this.dialogVisible = false;
  199. })
  200. .catch(() => {
  201. this.dialogVisible = false;
  202. });
  203. });
  204. },
  205. // 编辑
  206. editCustomer() {
  207. this.$refs.ruleForm.validate((valid) => {
  208. if (!valid) return;
  209. this.$api.http
  210. .InvalidReceptionUpdateInvalid(this.ruleForm)
  211. .then((res) => {
  212. this.dialogVisible = false;
  213. if (res.code == 10000) {
  214. this.$message({
  215. message: res.message,
  216. type: "success",
  217. });
  218. this.initRuleForm();
  219. this.getList();
  220. } else {
  221. this.$message({
  222. message: res.message,
  223. type: "error",
  224. });
  225. }
  226. })
  227. .catch(() => {
  228. this.dialogVisible = false;
  229. });
  230. });
  231. },
  232. // 删除确认删除item
  233. deleteItem() {
  234. if (!this.deleteParams.moveId) {
  235. this.$message({
  236. message: "请将此无效的接待转移到以下无效原因中",
  237. type: "error",
  238. });
  239. return;
  240. }
  241. this.$api.http
  242. .InvalidReceptionDelete(this.deleteParams)
  243. .then((res) => {
  244. console.log(res);
  245. this.delVisible = false;
  246. if (res.code == 10000) {
  247. this.$message({
  248. message: res.message,
  249. type: "success",
  250. });
  251. } else {
  252. this.$message({
  253. message: res.message,
  254. type: "error",
  255. });
  256. }
  257. this.deleteParams.moveId = "";
  258. this.getList();
  259. })
  260. .catch(() => {
  261. this.delVisible = false;
  262. });
  263. },
  264. // 获取列表
  265. getList() {
  266. this.$api.http
  267. .InvalidReceptionReasonList({
  268. houseId: this.paramsList.houseId,
  269. })
  270. .then((res) => {
  271. if (res.code == 10000) {
  272. this.tableData = res.data.filter(
  273. (item) => item.id != 6 && item.id != 7 && item.id != 5
  274. );
  275. }
  276. this.$nextTick(() => {
  277. this.loadingObj.close();
  278. });
  279. })
  280. .catch(() => {
  281. this.$nextTick(() => {
  282. this.loadingObj.close();
  283. });
  284. });
  285. },
  286. //行拖拽
  287. rowDrop() {
  288. const transfer = this.$refs.tableSortable.$el;
  289. const tbody = transfer
  290. .getElementsByClassName("el-table__body-wrapper")[0]
  291. .getElementsByClassName("el-table__body")[0]
  292. .getElementsByTagName("tbody")[0];
  293. console.log(tbody, "tbody");
  294. Sortable.create(tbody, {
  295. animation: 100,
  296. onEnd: ({ newIndex, oldIndex }) => {
  297. console.log(newIndex, oldIndex);
  298. if (newIndex == oldIndex) {
  299. return;
  300. }
  301. this.loadingObj = Loading.service({
  302. lock: true,
  303. text: "Loading",
  304. spinner: "el-icon-loading",
  305. background: "rgba(0, 0, 0, 0.7)",
  306. });
  307. this.$api.http
  308. .InvalidReceptionUpdateSort({
  309. houseId: this.paramsList.houseId,
  310. id: this.tableData[newIndex].id,
  311. sort: this.tableData[oldIndex].sort,
  312. moveId: this.tableData[oldIndex].id, // 更换的id
  313. moveSort: this.tableData[newIndex].sort, // 更换的序号
  314. })
  315. .then((res) => {
  316. console.log(res);
  317. if (res.code == 10000) {
  318. this.$message({
  319. message: res.message,
  320. type: "success",
  321. });
  322. this.tableData = [];
  323. this.getList();
  324. } else {
  325. this.$message({
  326. message: res.message,
  327. type: "error",
  328. });
  329. this.loadingObj.close();
  330. }
  331. });
  332. },
  333. });
  334. },
  335. //删除
  336. del(item) {
  337. this.delIdList = [];
  338. this.deleteParams.id = item.id;
  339. this.deleteParams.sort = item.sort;
  340. let arr = [];
  341. this.tableData.forEach((items) => {
  342. if (items.id != item.id) {
  343. arr.push({
  344. label: items.name,
  345. value: items.id,
  346. });
  347. }
  348. });
  349. console.log(arr);
  350. this.delIdList = arr;
  351. this.delVisible = true;
  352. },
  353. //编辑
  354. bianji(row) {
  355. this.dialogVisible = true;
  356. this.ruleForm.name = row.name;
  357. this.ruleForm.id = row.id;
  358. this.editFlag = true;
  359. },
  360. editorinfo() {
  361. this.dialogVisible = true;
  362. this.editFlag = false;
  363. this.ruleForm.editFlag = "";
  364. },
  365. },
  366. };
  367. </script>
  368. <style lang="scss" scoped>
  369. .box-center {
  370. width: 100%;
  371. min-height: 100%;
  372. padding: 15px;
  373. min-width: 1000px;
  374. padding-bottom: 100px;
  375. }
  376. .cen-tab {
  377. width: 100%;
  378. padding: 15px;
  379. background: #ffffff;
  380. margin-top: 15px;
  381. min-height: 100%;
  382. }
  383. .tophove {
  384. color: #ffffff;
  385. background: #2671e2;
  386. }
  387. .dtit-box {
  388. width: 100%;
  389. display: flex;
  390. align-items: center;
  391. flex-wrap: wrap;
  392. }
  393. .div-lab1 {
  394. display: flex;
  395. align-items: center;
  396. margin: 5px;
  397. }
  398. .label1 {
  399. font-size: 14px;
  400. color: #32363d;
  401. line-height: 32px;
  402. margin-left: 6px;
  403. }
  404. .app-top {
  405. width: 100%;
  406. background: #ffffff;
  407. box-shadow: 0px 0px 12px 0px rgba(0, 0, 0, 0.04);
  408. border-radius: 4px;
  409. padding-top: 15px;
  410. padding-bottom: 15px;
  411. }
  412. .app-titel {
  413. width: 100%;
  414. display: flex;
  415. align-items: center;
  416. flex-wrap: wrap;
  417. }
  418. .label {
  419. font-size: 14px;
  420. font-weight: 400;
  421. color: #32363d;
  422. line-height: 32px;
  423. margin-left: 15px;
  424. min-width: 100px;
  425. text-align: right;
  426. }
  427. .toptimeqhuan {
  428. height: 30px;
  429. background: #ffffff;
  430. display: flex;
  431. align-items: center;
  432. }
  433. .toptimeqhuan div {
  434. padding-left: 20px;
  435. padding-right: 20px;
  436. text-align: center;
  437. line-height: 30px;
  438. font-size: 14px;
  439. margin-right: 15px;
  440. border-radius: 4px;
  441. border: 1px solid #e0e0e0;
  442. }
  443. .div-lab {
  444. display: flex;
  445. margin: 5px;
  446. }
  447. .div-inp {
  448. width: 250px;
  449. }
  450. .el-tooltip__popper {
  451. max-width: 300px;
  452. }
  453. </style>