index.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <template>
  2. <div class="page-container list-container">
  3. <!-- 功能按钮区 -->
  4. <div class="list-btns-container">
  5. <el-button type="primary" size="small" icon="Plus" @click="handleAdd"
  6. v-hasPermi="['oncePrice:oncePrice:save']">新增</el-button>
  7. <el-button type="danger" size="small" icon="Delete" :disabled="multiple" @click="handleDelete"
  8. v-hasPermi="['oncePrice:oncePrice:remove']">删除</el-button>
  9. <el-button type="info" size="small" icon="Download" @click="handleExport"
  10. v-hasPermi="['oncePrice:oncePrice:export']">导出</el-button>
  11. </div>
  12. <!-- 搜索区 -->
  13. <el-form class="list-search-container" size="small" :model="queryParams" ref="queryRef" :inline="true"
  14. label-width="60px">
  15. <el-form-item label="任务类型:" prop="taskTypeId">
  16. <el-select v-model="queryParams.taskTypeId" type="text" placeholder="选择任务" :clearable="true" width="100px"
  17. @change="handleTaskChange" @clear="handleTaskClear">
  18. <el-option v-for="item in taskType" :key="item.id" :label="item.name" :value="item.id" />
  19. </el-select>
  20. </el-form-item>
  21. <el-form-item label="任务明细:" prop="fromAccountName">
  22. <el-select v-model="queryParams.taskTypeDetailId" type="text" placeholder="先选择任务类型" :clearable="true"
  23. width="100px" @clear="handleTaskDetaiClear">
  24. <el-option v-for="item in taskTypeDetail" :key="item.id" :label="item.name" :value="item.id" />
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item label="省市区:" prop="provinceCode" style="width: 300px">
  28. <el-select v-model="queryParams.provinceCode" placeholder="省份" style="width: 33%" @change="handleSelectProvince">
  29. <el-option v-for="item in provinces" :key="item.code" :label="item.name" :value="item.code" />
  30. </el-select>
  31. <el-select v-model="queryParams.cityCode" placeholder="城市" style="width: 33%" @change="handleSelectCity">
  32. <el-option v-for="item in cities" :key="item.code" :label="item.name" :value="item.code" />
  33. </el-select>
  34. <el-select v-model="queryParams.districtCode" placeholder="行政区" style="width: 33%" @change="handleSelectDistrict">
  35. <el-option v-for="item in districts" :key="item.code" :label="item.name" :value="item.code" />
  36. </el-select>
  37. </el-form-item>
  38. <el-form-item>
  39. <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
  40. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  41. </el-form-item>
  42. </el-form>
  43. <!-- 列表区 -->
  44. <el-table v-loading="loading" :data="priceListList" size="small" border height="100%"
  45. @selection-change="handleSelectionChange">
  46. <el-table-column type="selection" width="55" align="center" />
  47. <!-- <el-table-column label="序号" align="center" type="index">
  48. </el-table-column> -->
  49. <el-table-column label="地区" min-width="250" align="center" prop="taskTypeName">
  50. <template #default="scope">
  51. <span>{{ scope.row.province }}-{{ scope.row.city }}-{{
  52. scope.row.district
  53. }}</span>
  54. </template>
  55. </el-table-column>
  56. <el-table-column label="任务类型" align="center" min-width="100" prop="taskTypeName">
  57. </el-table-column>
  58. <el-table-column label="任务明细" min-width="100" align="center" prop="taskTypeDetailName">
  59. <template #default="scope">
  60. <span v-if="scope.row.taskTypeId == 6">{{ scope.row.alterType }}-{{ scope.row.taskTypeDetailName }}
  61. </span>
  62. <span v-else>{{ scope.row.taskTypeDetailName }} </span>
  63. </template>
  64. </el-table-column>
  65. <el-table-column label="金额" header-align="center" align="right" min-width="80" prop="price" />
  66. <el-table-column label="备注" align="center" min-width="100" prop="remark" />
  67. <el-table-column label="操作" align="center" min-width="100" class-name="small-padding fixed-width">
  68. <template #default="scope">
  69. <el-button link type="warning" size="small" @click="handleUpdate(scope.row)"
  70. v-hasPermi="['oncePrice:oncePrice:save']">修改</el-button>
  71. <el-button link type="danger" size="small" @click="handleDelete(scope.row)"
  72. v-hasPermi="['oncePrice:oncePrice:remove']">删除</el-button>
  73. </template>
  74. </el-table-column>
  75. </el-table>
  76. <!-- 分页 -->
  77. <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize"
  78. @pagination="getList" />
  79. <!-- 表单 -->
  80. <priceList-form ref="priceListRef" :get-list="getList"></priceList-form>
  81. </div>
  82. </template>
  83. <script setup name="PriceList">
  84. import {
  85. listOncePrice,
  86. delOncePrice,
  87. getTaskTypeList,
  88. getTaskTypeDetailList,
  89. } from "@/api/system/oncePrice";
  90. import { yesOrNo } from "@/utils/default";
  91. import priceListForm from "./formDialog";
  92. const { proxy } = getCurrentInstance();
  93. /** 字典数组区 */
  94. /** 查询 对象 */
  95. const priceListList = ref([]);
  96. const loading = ref(true);
  97. const ids = ref([]);
  98. const single = ref(true);
  99. const provinces = ref(proxy.region.getProvinces());
  100. provinces.value.unshift({ code: "", name: "全部" });
  101. const cities = ref([]);
  102. const districts = ref([]);
  103. const multiple = ref(true);
  104. const total = ref(0);
  105. /** 任务类型 */
  106. const taskType = ref([]);
  107. /** 任务类型明细 */
  108. const taskTypeDetail = ref({});
  109. /** 查询对象 */
  110. const queryParams = ref({
  111. pageNum: 1,
  112. pageSize: 20,
  113. price: null,
  114. annualIncome: null,
  115. isChanged: null,
  116. fromTenantId: null,
  117. toTenantId: null,
  118. });
  119. /*********************** 方法区 ****************************/
  120. /** 查询价目表系统列表 */
  121. function getList() {
  122. loading.value = true;
  123. listOncePrice(queryParams.value).then((response) => {
  124. priceListList.value = response.rows;
  125. console.log("查询响应", response);
  126. console.log("表单", priceListList.value);
  127. total.value = response.total;
  128. loading.value = false;
  129. initRegion();
  130. });
  131. //查询任务类型
  132. getTaskTypeList().then((res) => {
  133. taskType.value = res.data;
  134. });
  135. }
  136. /** 清除选择任务 */
  137. function handleTaskClear() {
  138. queryParams.value.taskTypeId = null;
  139. }
  140. /** 初始化地区 */
  141. function initRegion() {
  142. cities.value = proxy.region.getCities(queryParams.value.provinceCode);
  143. districts.value = proxy.region.getDistricts(queryParams.value.cityCode);
  144. }
  145. /** 任务切换事件 */
  146. function handleTaskChange(item) {
  147. if (item) {
  148. getTaskTypeDetailList(item).then((res) => {
  149. taskTypeDetail.value = res.data;
  150. });
  151. } else {
  152. taskTypeDetail.value = [];
  153. }
  154. }
  155. /** 搜索按钮操作 */
  156. function handleQuery() {
  157. queryParams.value.pageNum = 1;
  158. getList();
  159. }
  160. /** 重置按钮操作 */
  161. function resetQuery() {
  162. proxy.resetForm("queryRef");
  163. queryParams.value.cityCode = "";
  164. queryParams.value.districtCode = "";
  165. handleQuery();
  166. }
  167. // 多选框选中数据
  168. function handleSelectionChange(selection) {
  169. ids.value = selection.map((item) => item.id);
  170. single.value = selection.length != 1;
  171. multiple.value = !selection.length;
  172. }
  173. /** 新增按钮操作 */
  174. function handleAdd() {
  175. proxy.$refs.priceListRef.open();
  176. }
  177. /** 修改按钮操作 */
  178. function handleUpdate(row) {
  179. const id = row.id || ids.value;
  180. proxy.$refs.priceListRef.open(id, row);
  181. }
  182. /** 删除按钮操作 */
  183. function handleDelete(row) {
  184. const _ids = row.id || ids.value;
  185. proxy.$modal
  186. .confirm("是否确认删除选中的数据项?")
  187. .then(function () {
  188. return delOncePrice(_ids);
  189. })
  190. .then(() => {
  191. getList();
  192. proxy.$modal.msgSuccess("删除成功!");
  193. })
  194. .catch(() => { });
  195. }
  196. /** 导出按钮操作 */
  197. function handleExport() {
  198. proxy.download(
  199. "priceList/priceList/export",
  200. {
  201. ...queryParams.value,
  202. },
  203. `priceList_${new Date().getTime()}.xlsx`
  204. );
  205. }
  206. function handleSelectProvince() {
  207. const _provinceCode = queryParams.value.provinceCode;
  208. const _province = provinces.value.find(function (item) {
  209. return item.code === _provinceCode;
  210. });
  211. queryParams.value.province = _province.name;
  212. cities.value = proxy.region.getCities(_provinceCode);
  213. if (cities.value.length === 0) {
  214. // 清空城市数据
  215. queryParams.value.cityCode = "";
  216. queryParams.value.city = "";
  217. cities.value = [{ code: "", name: "全部" }];
  218. // 清空行政区数据
  219. queryParams.value.districtCode = "";
  220. queryParams.value.district = "";
  221. districts.value = [];
  222. } else {
  223. cities.value.unshift({ code: "", name: "全部" });
  224. queryParams.value.cityCode = cities.value[0].code;
  225. queryParams.value.city = cities.value[0].name;
  226. handleSelectCity();
  227. }
  228. }
  229. function handleSelectCity() {
  230. const _cityCode = queryParams.value.cityCode;
  231. const _city = cities.value.find(function (item) {
  232. return item.code === _cityCode;
  233. });
  234. queryParams.value.city = _city.name;
  235. districts.value = proxy.region.getDistricts(_cityCode);
  236. if (districts.value.length === 0) {
  237. // 清空行政区数据
  238. queryParams.value.districtCode = "";
  239. queryParams.value.district = "";
  240. districts.value = [{ code: "", name: "全部" }];
  241. } else {
  242. districts.value.unshift({ code: "", name: "全部" });
  243. queryParams.value.districtCode = districts.value[0].code;
  244. queryParams.value.district = districts.value[0].name;
  245. }
  246. }
  247. function handleSelectDistrict() {
  248. const _districtCode = queryParams.value.districtCode;
  249. const _district = districts.value.find(function (item) {
  250. return item.code === _districtCode;
  251. });
  252. queryParams.value.district = _district.name;
  253. }
  254. getList();
  255. </script>