index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item prop="factoryName">
  5. <el-input v-model="queryParams.factoryName" placeholder="请输入工厂名称" clearable @keyup.enter.native="handleQuery" />
  6. </el-form-item>
  7. <el-form-item style="margin-left: 10px">
  8. <el-select size="small" style="width: 200px" v-model="province" placeholder="请选择省份(直辖市)" v-on:change="changeProvince()">
  9. <el-option v-for="item in provinces" :label="item.areaName" :value="item.areaId" :key="item.areaName"> </el-option>
  10. </el-select>
  11. </el-form-item>
  12. <el-form-item style="margin-left: 10px">
  13. <el-select size="small" style="width: 200px" v-model="city" placeholder="请选择城市" v-on:change="changeCity">
  14. <el-option v-for="item in citys" :label="item.areaName" :value="item.areaId" :key="item.areaName"> </el-option>
  15. </el-select>
  16. </el-form-item>
  17. <el-form-item prop="area" style="margin-left: 10px">
  18. <el-select size="small" style="width: 200px" v-model="area" placeholder="请选择区(县)">
  19. <el-option v-for="item in areas" :label="item.areaName" :value="item.areaId" :key="item.areaName"> </el-option>
  20. </el-select>
  21. </el-form-item>
  22. <el-form-item>
  23. <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
  24. <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
  25. </el-form-item>
  26. </el-form>
  27. <el-row :gutter="10" class="mb8">
  28. <el-col :span="1.5">
  29. <el-button type="primary" plain icon="el-icon-plus" @click="handleAdd" v-hasPermi="['system:factory:add']">新增 </el-button>
  30. </el-col>
  31. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  32. </el-row>
  33. <Page uri="/system/factory/list" :request-params="queryParams" ref="pagination">
  34. <el-table-column label="id" align="center" prop="id" />
  35. <el-table-column label="工厂名称" align="center" prop="factoryName" />
  36. <el-table-column label="负责人名称" align="center" prop="applyName" />
  37. <el-table-column label="负责人-身份证号码" align="center" prop="applyIdCard" v-if="false" />
  38. <el-table-column label="负责人-联系方式" align="center" prop="applyPhone" />
  39. <el-table-column label="经度" align="center" prop="orgLon" v-if="false" />
  40. <el-table-column label="纬度" align="center" prop="orgLat" v-if="false" />
  41. <el-table-column label="所属省份" align="center" prop="province" />
  42. <el-table-column label="所属城市" align="center" prop="city" />
  43. <el-table-column label="所属地区" align="center" prop="area" />
  44. <el-table-column label="地址" align="center" prop="address" :show-overflow-tooltip="true" />
  45. <el-table-column label="状态" align="center" key="status">
  46. <template slot-scope="scope">
  47. <el-switch v-model="scope.row.status" active-value="0" inactive-value="1" @change="handleStatusChange(scope.row)"></el-switch>
  48. </template>
  49. </el-table-column>
  50. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  51. <template slot-scope="scope">
  52. <el-button type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:factory:edit']">修改 </el-button>
  53. <el-button type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['system:factory:remove']" v-if="scope.row.id !== 1">删除 </el-button>
  54. </template>
  55. </el-table-column>
  56. </Page>
  57. <el-dialog :title="title" :visible.sync="open" direction="rtl" size="50%" append-to-body @opened="onDialogOpened" destroy-on-close>
  58. <Add_factory ref="AddFactory" @closeDialog="closeDialog" />
  59. </el-dialog>
  60. </div>
  61. </template>
  62. <script>
  63. import request from '@/utils/request'
  64. import Add_factory from '@/views/system/factory/add_factory.vue'
  65. export function listArea(query) {
  66. return request({
  67. url: '/system/area/list',
  68. method: 'get',
  69. params: query
  70. })
  71. }
  72. import { listFactory, getFactory, delFactory, addFactory, updateFactory, changeFactoryStatus } from '@/api/system/factory'
  73. export default {
  74. name: 'Factory',
  75. components: {
  76. Add_factory
  77. },
  78. data() {
  79. return {
  80. // 遮罩层
  81. loading: true,
  82. // 选中数组
  83. ids: [],
  84. // 非单个禁用
  85. single: true,
  86. // 非多个禁用
  87. multiple: true,
  88. // 显示搜索条件
  89. showSearch: true,
  90. // 总条数
  91. total: 0,
  92. // 工厂 基本信息表格数据
  93. factoryList: [],
  94. // 弹出层标题
  95. title: '',
  96. // 是否显示弹出层
  97. open: false,
  98. // 查询参数
  99. queryParams: {
  100. factoryName: null,
  101. applyName: null,
  102. applyIdCard: null,
  103. applyPhone: null,
  104. address: null,
  105. orgLon: null,
  106. orgLat: null,
  107. province: null,
  108. city: null,
  109. area: null,
  110. content: null,
  111. businessLicensePic: null,
  112. factoryPic: null,
  113. status: null
  114. },
  115. // 表单参数
  116. form: {},
  117. // 表单校验
  118. rules: {
  119. factoryName: [
  120. {
  121. required: true,
  122. message: '请输入工厂名称',
  123. trigger: 'blur'
  124. }
  125. ]
  126. },
  127. province: '', // 省
  128. city: '', // 市
  129. area: '', // 区
  130. provinces: [],
  131. citys: [],
  132. areas: []
  133. }
  134. },
  135. created() {
  136. this.getList()
  137. this.getProvince()
  138. // 监听自定义的 refreshList 事件
  139. this.$root.$on('refreshList', () => {
  140. this.getList()
  141. })
  142. },
  143. methods: {
  144. checkClose(done) {
  145. this.$confirm('是否关闭表单,关闭后数据将丢失?')
  146. .then(function () {
  147. done()
  148. })
  149. .then(() => {})
  150. .catch(() => {})
  151. },
  152. /** 查询工厂 基本信息列表 */
  153. getList() {
  154. this.queryParams.provinceId = this.province
  155. this.queryParams.cityId = this.city
  156. this.queryParams.areaId = this.area
  157. this.$nextTick(() => {
  158. this.$refs.pagination.handleSearch(true)
  159. })
  160. },
  161. // 工厂状态修改
  162. handleStatusChange(row) {
  163. let text = row.status === '0' ? '启用' : '停用'
  164. this.$modal
  165. .confirm('确认要' + text + ' ' + row.factoryName + ' 吗?')
  166. .then(function () {
  167. return changeFactoryStatus(row.id, row.status)
  168. })
  169. .then(() => {
  170. this.$modal.msgSuccess(text + '成功')
  171. })
  172. .catch(function () {
  173. row.status = row.status === '0' ? '1' : '0'
  174. })
  175. },
  176. /** 获取省份 */
  177. getProvince() {
  178. let provinceParams = {
  179. level: 1
  180. }
  181. listArea(provinceParams).then((response) => {
  182. this.provinces = response.data
  183. })
  184. },
  185. /** 获取城市 */
  186. changeProvince() {
  187. let cityParams = {
  188. parentId: this.province
  189. }
  190. listArea(cityParams).then((response) => {
  191. this.citys = response.data
  192. })
  193. if (this.city != null) {
  194. this.city = null
  195. this.area = null
  196. this.areas = []
  197. }
  198. },
  199. /** 获取区县 */
  200. changeCity() {
  201. let cityParams = {
  202. parentId: this.city
  203. }
  204. listArea(cityParams).then((response) => {
  205. this.areas = response.data
  206. })
  207. if (this.area != null) {
  208. this.area = null
  209. }
  210. },
  211. // 取消按钮
  212. cancel() {
  213. this.open = false
  214. this.reset()
  215. },
  216. // 表单重置
  217. reset() {
  218. this.form = {
  219. id: null,
  220. factoryName: null,
  221. applyName: null,
  222. applyIdCard: null,
  223. applyPhone: null,
  224. address: null,
  225. orgLon: null,
  226. orgLat: null,
  227. province: null,
  228. city: null,
  229. area: null,
  230. content: null,
  231. businessLicensePic: null,
  232. factoryPic: null,
  233. status: null,
  234. delFlag: null,
  235. createBy: null,
  236. createTime: null,
  237. updateBy: null,
  238. updateTime: null,
  239. remark: null
  240. }
  241. this.resetForm('form')
  242. },
  243. /** 搜索按钮操作 */
  244. handleQuery() {
  245. this.getList()
  246. },
  247. /** 重置按钮操作 */
  248. resetQuery() {
  249. this.province = ''
  250. this.city = ''
  251. this.citys = []
  252. this.area = ''
  253. this.areas = []
  254. this.resetForm('queryForm')
  255. this.handleQuery()
  256. },
  257. /** 新增按钮操作 */
  258. handleAdd() {
  259. this.reset()
  260. this.open = true
  261. this.id = ''
  262. this.title = '新增工厂'
  263. },
  264. /** 修改按钮操作 */
  265. handleUpdate(row) {
  266. this.reset()
  267. this.open = true
  268. this.title = '修改工厂'
  269. this.id = row.id
  270. },
  271. /** 删除按钮操作 */
  272. handleDelete(row) {
  273. const ids = row.id || this.ids
  274. this.$modal
  275. .confirm('是否确认删除工厂名称为"' + row.factoryName + '"的数据项?')
  276. .then(function () {
  277. return delFactory(ids)
  278. })
  279. .then(() => {
  280. this.getList()
  281. this.$modal.msgSuccess('删除成功')
  282. })
  283. .catch(() => {})
  284. },
  285. onDialogOpened() {
  286. this.$refs.AddFactory.setInitData(this.id)
  287. },
  288. closeDialog() {
  289. this.open = false
  290. }
  291. },
  292. destroyed() {
  293. // 取消事件监听
  294. this.$root.$off('getList')
  295. }
  296. }
  297. </script>