index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <template>
  2. <div>
  3. <basic-container v-show="show" class="page-crad">
  4. <avue-crud ref="crud" :option="option" :data="dataList" v-model="form" :page.sync="page" :search.sync="search"
  5. :table-loading="loading" :cell-style="cellStyle" @selection-change="selectionChange"
  6. @search-change="searchChange" @current-change="currentChange" @size-change="sizeChange"
  7. @refresh-change="refreshChange" @on-load="onLoad" @search-criteria-switch="searchCriteriaSwitch"
  8. @saveColumn="saveColumn" @resetColumn="resetColumn">
  9. <template slot="menuLeft">
  10. <el-button type="primary" icon="el-icon-plus" size="small" @click.stop="newAdd()">创建单据</el-button>
  11. <el-button type="success" size="small" icon="el-icon-plus" @click.stop="copyDoc()"
  12. :disabled="selection.length != 1" v-if="false">复制单据</el-button>
  13. </template>
  14. <template slot-scope="scope" slot="menu">
  15. <el-button type="text" icon="el-icon-delete" size="small" @click.stop="rowDel(scope.row, scope.index)"
  16. :disabled="scope.row.status == 1">删除
  17. </el-button>
  18. </template>
  19. <template slot="corpNameSearch">
  20. <crop-select v-model="search.corpId" corpType="KH"></crop-select>
  21. </template>
  22. <template slot="fromUserNameSearch">
  23. <el-select v-model="search.fromUser" filterable clearable placeholder="请选择 承揽人">
  24. <el-option v-for="(item, index) in contractorOption" :key="index" :value="item.id" :label="item.realName">
  25. </el-option>
  26. </el-select>
  27. </template>
  28. <template slot="toUserNameSearch">
  29. <el-select v-model="search.toUser" filterable clearable placeholder="请选择 承揽人">
  30. <el-option v-for="(item, index) in oppositePersonOption" :key="index" :value="item.id"
  31. :label="item.realName"></el-option>
  32. </el-select>
  33. </template>
  34. <template slot="corpName" slot-scope="scope">
  35. <span style="color: #409EFF;cursor: pointer" @click.stop="beforeOpenPage(scope.row, scope.index)">{{
  36. scope.row.corpName
  37. }}</span>
  38. </template>
  39. </avue-crud>
  40. </basic-container>
  41. <detail-page @goBack="goBack" @copyOrder="copyOrder" :detailData="detailData" v-if="!show" />
  42. </div>
  43. </template>
  44. <script>
  45. import option from "./config/mainList.json";
  46. import detailPage from "./detail";
  47. import { gainUser } from "@/api/basicData/customerInquiry";
  48. import { getList, deleteList } from "@/api/standAlone/saleLeads";
  49. export default {
  50. name: "index",
  51. components: {
  52. detailPage,
  53. },
  54. data() {
  55. return {
  56. option: {},
  57. dataList: [],
  58. form: {},
  59. page: {
  60. pageSize: 10,
  61. currentPage: 1,
  62. total: 0,
  63. pageSizes: [10, 50, 100, 200, 300, 400, 500]
  64. },
  65. search: {},
  66. show: true,
  67. loading: false,
  68. selection: [],
  69. detailData: {},
  70. contractorOption: [],
  71. oppositePersonOption: [],
  72. }
  73. },
  74. activated() {
  75. if (!this.show && !this.$store.getters.xsjhStatus) {
  76. this.show = true;
  77. }
  78. setTimeout(() => {
  79. if (this.$route.query.check && this.show) {
  80. this.detailData = {
  81. check: this.$route.query.check
  82. }
  83. this.show = false;
  84. this.$store.commit("XSJH_IN_DETAIL");
  85. } else if (this.$route.query.params) {
  86. this.detailData = {
  87. id: this.$route.query.params,
  88. view: true,
  89. }
  90. this.show = false;
  91. this.$store.commit("XSJH_IN_DETAIL");
  92. }
  93. }, 100);
  94. },
  95. async created() {
  96. this.option = await this.getColumnData(this.getColumnName(101), option);
  97. gainUser().then(res => {
  98. this.contractorOption = res.data.data;
  99. this.oppositePersonOption = res.data.data;
  100. })
  101. let i = 0;
  102. this.option.column.forEach(item => {
  103. if (item.search) i++
  104. })
  105. if (i % 3 !== 0) {
  106. const num = 3 - Number(i % 3)
  107. this.option.searchMenuSpan = num * 8;
  108. this.option.searchMenuPosition = "right";
  109. }
  110. },
  111. methods: {
  112. searchCriteriaSwitch(type) {
  113. if (type) {
  114. this.option.height = this.option.height - 90
  115. } else {
  116. this.option.height = this.option.height + 90
  117. }
  118. this.$refs.crud.getTableHeight()
  119. },
  120. newAdd() {
  121. this.show = false;
  122. this.$store.commit("XSJH_IN_DETAIL");
  123. },
  124. onLoad(page, params) {
  125. // 重置掉展开
  126. this.dataList.forEach(item => {
  127. this.$refs.crud.toggleRowExpansion(item, false)
  128. })
  129. let queryParams = Object.assign({}, params, {
  130. size: page.pageSize,
  131. current: page.currentPage,
  132. })
  133. if (queryParams.bizDate && queryParams.bizDate.length > 0) {
  134. queryParams = {
  135. ...queryParams,
  136. beginBizDate: queryParams.bizDate[0] + ' 00:00:00',
  137. endBizDate: queryParams.bizDate[1] + ' 23:59:59',
  138. }
  139. }
  140. delete queryParams.bizDate;
  141. this.loading = true;
  142. getList(queryParams).then(res => {
  143. this.dataList = res.data.data.records;
  144. this.page.total = res.data.data.total;
  145. this.option.height = window.innerHeight - 240;
  146. this.$nextTick(() => {
  147. this.$refs.crud.doLayout()
  148. })
  149. }).finally(() => {
  150. this.loading = false;
  151. })
  152. },
  153. async saveColumn() {
  154. const inSave = await this.saveColumnData(
  155. this.getColumnName(101),
  156. this.option
  157. );
  158. if (inSave) {
  159. this.$message.success("保存成功");
  160. //关闭窗口
  161. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  162. this.$nextTick(() => {
  163. this.$refs.crud.doLayout()
  164. })
  165. }
  166. },
  167. async resetColumn() {
  168. this.option = option;
  169. const inSave = await this.delColumnData(this.getColumnName(101), option);
  170. if (inSave) {
  171. this.$nextTick(() => {
  172. this.$refs.crud.doLayout()
  173. })
  174. this.$message.success("重置成功");
  175. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  176. }
  177. },
  178. //点击搜索按钮触发
  179. searchChange(params, done) {
  180. this.onLoad(this.page, params);
  181. done();
  182. },
  183. currentChange(val) {
  184. this.page.currentPage = val;
  185. },
  186. sizeChange(val) {
  187. this.page.currentPage = 1;
  188. this.page.pageSize = val;
  189. },
  190. refreshChange() {
  191. this.onLoad(this.page, this.search);
  192. },
  193. cellStyle() {
  194. return "padding:0;height:40px;";
  195. },
  196. copyDoc() { },
  197. selectionChange(list) {
  198. this.selection = list;
  199. },
  200. goBack() {
  201. if (this.$route.query.check) {
  202. this.$router.$avueRouter.closeTag(this.$route.fullPath);
  203. this.$router.push({
  204. path: "/saleLeads/index"
  205. });
  206. }
  207. this.detailData = this.$options.data().detailData;
  208. this.$store.commit('XSJH_OUT_DETAIL');
  209. this.show = true;
  210. this.onLoad(this.page, this.search);
  211. },
  212. copyOrder(id) {
  213. this.show = true;
  214. this.detailData = {
  215. id: id,
  216. status: "copy"
  217. };
  218. this.$nextTick(() => {
  219. this.show = false;
  220. });
  221. },
  222. contractorRemoteMethod(name) {
  223. gainUser({ realName: name }).then(res => {
  224. this.contractorOption = res.data.data;
  225. })
  226. },
  227. oppositePersonRemoteMethod(name) {
  228. gainUser({ realName: name }).then(res => {
  229. this.oppositePerson = res.data.data;
  230. })
  231. },
  232. // 详情打开
  233. beforeOpenPage(row, index) {
  234. this.show = false;
  235. this.detailData = {
  236. id: row.id,
  237. query: true, // 表示只是查询
  238. };
  239. },
  240. //删除列表后面的删除按钮触发触发(row, index, done)
  241. rowDel(row, index, done) {
  242. this.$confirm("确定删除数据?", {
  243. confirmButtonText: "确定",
  244. cancelButtonText: "取消",
  245. type: "warning"
  246. }).then(res => {
  247. return deleteList(row.id)
  248. }).then(() => {
  249. this.dataList.splice(row.$index, 1)
  250. this.$message({
  251. type: "success",
  252. message: "删除成功!"
  253. });
  254. this.page.currentPage = 1;
  255. this.onLoad(this.page)
  256. })
  257. },
  258. },
  259. }
  260. </script>
  261. <style scoped>
  262. </style>