index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. <template>
  2. <div>
  3. <div v-if="!openDetail">
  4. <el-card>
  5. <el-form size="mini" class="search_area" label-width="120px">
  6. <el-row :gutter="10">
  7. <el-col :span="1.5">
  8. <el-form-item label="客户名称">
  9. <el-input
  10. v-model="queryParams.customerName"
  11. clearable
  12. />
  13. </el-form-item>
  14. </el-col>
  15. <el-col :span="1.5">
  16. <el-form-item label="年度">
  17. <el-date-picker
  18. v-model="queryParams.month"
  19. type="month"
  20. value-format="yyyy-MM"
  21. clearable
  22. >
  23. </el-date-picker>
  24. </el-form-item>
  25. </el-col>
  26. <el-col :span="1.5">
  27. <el-form-item label="创建人">
  28. <el-input
  29. v-model="queryParams.createByName"
  30. clearable
  31. />
  32. </el-form-item>
  33. </el-col>
  34. <el-col :span="1.5">
  35. <el-form-item label="部门">
  36. <el-input
  37. v-model="queryParams.deptName"
  38. clearable
  39. />
  40. </el-form-item>
  41. </el-col>
  42. <el-col :span="1.5">
  43. <el-form-item label="" label-width="20px">
  44. <el-button type="primary" size="mini" icon="el-icon-search" plain @click="useSearch">搜索</el-button>
  45. <el-button size="mini" icon="el-icon-refresh" plain @click="useReset">重置</el-button>
  46. </el-form-item>
  47. </el-col>
  48. </el-row>
  49. </el-form>
  50. <el-divider></el-divider>
  51. <div class="btn_grooup">
  52. <el-button type="primary" size="mini" @click="useAdd">新增</el-button>
  53. </div>
  54. <el-table
  55. :data="tableList"
  56. @row-dblclick="useDoubleClick"
  57. v-loading="loading"
  58. height="600px"
  59. >
  60. <el-table-column label="序号" type="index" width="50" align="center" fixed/>
  61. <el-table-column show-overflow-tooltip label="编码" align="center" width="200" prop="code"/>
  62. <el-table-column show-overflow-tooltip label="客户名称" align="center" width="200" prop="customerName"/>
  63. <el-table-column show-overflow-tooltip label="月度" align="center" width="200" prop="month"/>
  64. <el-table-column show-overflow-tooltip label="部门" align="center" width="200" prop="deptName"/>
  65. <el-table-column show-overflow-tooltip label="创建人" align="center" width="200" prop="createByName" />
  66. <el-table-column show-overflow-tooltip label="创建时间" align="center" width="200" prop="createTime" />
  67. <el-table-column show-overflow-tooltip label="修改人" align="center" width="200" prop="updateByName" />
  68. <el-table-column show-overflow-tooltip label="修改时间" align="center" width="200" prop="updateTime" />
  69. <el-table-column fixed="right" label="操作" align="center" width="150">
  70. <template slot-scope="scope">
  71. <el-button type="text" size="mini" @click="useEdit(scope.row)">填报</el-button>
  72. <el-button type="text" size="mini" @click="useDel(scope.row)">删除</el-button>
  73. </template>
  74. </el-table-column>
  75. </el-table>
  76. <el-pagination
  77. background
  78. @size-change="useChangePageSize"
  79. @current-change="useCurrentChange"
  80. :current-page="queryParams.pageNum"
  81. :page-sizes="[10, 15, 20]"
  82. :page-size="100"
  83. layout="total, sizes, prev, pager, next, jumper"
  84. :total=total>
  85. </el-pagination>
  86. </el-card>
  87. </div>
  88. <Detail v-if="openDetail" :openMode="openMode" :row="row"/>
  89. <!-- 新增填报对话框 -->
  90. <el-dialog
  91. title="新增"
  92. :visible.sync="open"
  93. width="1000px"
  94. append-to-body
  95. >
  96. <el-form
  97. size="mini"
  98. :model="form"
  99. :rules="rules"
  100. ref="form"
  101. label-width="auto"
  102. >
  103. <el-row :gutter="10">
  104. <el-col :span="1.5">
  105. <el-form-item label="编码" prop="code">
  106. <el-input
  107. placeholder="自动生成"
  108. readonly
  109. v-model="form.code"
  110. style="width: 200px"
  111. clearable
  112. />
  113. </el-form-item>
  114. </el-col>
  115. <el-col :span="1.5">
  116. <el-form-item label="月份" prop="month">
  117. <el-date-picker
  118. :readonly="this.openMode == 'edit' || this.openMode == 'see'"
  119. v-model="form.month"
  120. value-format="yyyy-MM"
  121. type="month"
  122. clearable
  123. >
  124. </el-date-picker>
  125. </el-form-item>
  126. </el-col>
  127. <el-col :span="1.5">
  128. <el-form-item label="客户" prop="customer">
  129. <dr-popover-select
  130. :readonly="this.openMode == 'edit' || this.openMode == 'see'"
  131. size="mini"
  132. v-model="form.customerName"
  133. title="客户选择"
  134. type="CUSTOMER_PARAM_ZT"
  135. :dataMapping="{
  136. customer: 'id',
  137. customerName: 'name',
  138. }"
  139. :source.sync="form"
  140. >
  141. </dr-popover-select>
  142. </el-form-item>
  143. </el-col>
  144. <el-col :span="1.5">
  145. <el-form-item label="创建日期" prop="createTime">
  146. <el-input
  147. v-model="form.createTime"
  148. style="width: 200px"
  149. clearable
  150. readonly
  151. />
  152. </el-form-item>
  153. </el-col>
  154. <el-col :span="1.5">
  155. <el-form-item label="创建人" prop="createByName">
  156. <el-input
  157. v-model="form.createByName"
  158. style="width: 200px"
  159. clearable
  160. readonly
  161. />
  162. </el-form-item>
  163. </el-col>
  164. <el-col :span="1.5">
  165. <el-form-item label="部门" prop="deptName">
  166. <el-input
  167. v-model="form.deptName"
  168. style="width: 200px"
  169. clearable
  170. readonly
  171. />
  172. </el-form-item>
  173. </el-col>
  174. </el-row>
  175. </el-form>
  176. <div slot="footer">
  177. <el-button type="primary" @click="submitForm">确 定</el-button>
  178. <el-button @click="cancel">取 消</el-button>
  179. </div>
  180. </el-dialog>
  181. </div>
  182. </template>
  183. <script>
  184. import Detail from './detail.vue'
  185. import { addAssess,listAssess,delAssess, } from "@/api/business/spd/fillin/dailysale_quantity_assess";
  186. export default {
  187. name: "dailysaleQuantityAssess",
  188. components: {Detail},
  189. data() {
  190. return {
  191. loading: false,
  192. // 是否显示弹出层
  193. open: false,
  194. //新增表单
  195. form: {
  196. month: "",
  197. customer: "",
  198. customerName: "",
  199. },
  200. //表单校验
  201. rules: {
  202. month: [{ required: true, message: "月份不能为空", trigger: "blur" }],
  203. customer: [
  204. { required: true, message: "客户不能为空", trigger: "blur" },
  205. ],
  206. },
  207. // 搜索框参数
  208. queryParams: {
  209. customerName:null,
  210. month:null,
  211. deptName:null,
  212. deptName:null,
  213. pageNum: 1,
  214. pageSize: 10,
  215. },
  216. //总条数
  217. total: 0,
  218. //列表数据
  219. tableList:[],
  220. //是否打开详情页面
  221. openDetail:false,
  222. //编辑页面打开方式,add或edit或see
  223. openMode:'',
  224. //行数据
  225. row:{},
  226. };
  227. },
  228. created() {
  229. this.getList(this.queryParams);
  230. },
  231. methods: {
  232. //是否打开详情页面
  233. useOpenDetail(){
  234. this.openDetail = !this.openDetail;
  235. },
  236. //新增
  237. useAdd(){
  238. this.reset();
  239. this.form.createTime = this.getCurrentTime();
  240. this.form.month = this.getCurrentMonth();
  241. this.form.createByName = this.$store.state.user.nickName;
  242. this.form.dept = this.$store.state.user.deptId;
  243. this.form.deptName = this.$store.state.user.deptName;
  244. this.open = true;
  245. },
  246. //编辑
  247. async useEdit(row){
  248. this.openMode = 'edit';
  249. this.row = row;
  250. this.openDetail = true;
  251. },
  252. //删除
  253. async useDel(row){
  254. this.$modal.confirm('确认删除选择数据').then(() => {
  255. delAssess(row.id).then(res => {
  256. if (res.code === 200) {
  257. this.$modal.msgSuccess("删除成功");
  258. this.getList(this.queryParams);
  259. }
  260. })
  261. }).catch(() => {})
  262. },
  263. //查询列表
  264. getList(params){
  265. this.loading = true;
  266. listAssess(params).then(res => {
  267. if (res.code === 200) {
  268. this.tableList = res.rows
  269. this.total = res.total
  270. }
  271. this.loading = false;
  272. })
  273. },
  274. //双击
  275. useDoubleClick(row){
  276. this.openMode = 'see';
  277. this.row = row;
  278. this.openDetail = true;
  279. },
  280. //改变一页显示条数
  281. useChangePageSize(val){
  282. this.queryParams.pageSize = val
  283. this.getList(this.queryParams)
  284. },
  285. //翻页
  286. useCurrentChange(val){
  287. this.queryParams.pageNum = val
  288. this.getList(this.queryParams)
  289. },
  290. //搜索
  291. useSearch() {
  292. console.log(this.queryParams);
  293. this.getList(this.queryParams);
  294. },
  295. //重置
  296. useReset(){
  297. this.queryParams = {
  298. customerName:null,
  299. month:null,
  300. deptName:null,
  301. deptName:null,
  302. pageNum: 1,
  303. pageSize: 10,
  304. }
  305. this.getList(this.queryParams);
  306. },
  307. //重置表单
  308. reset(){
  309. this.form = {
  310. month: "",
  311. customer: "",
  312. customerName: "",
  313. }
  314. },
  315. // 确认
  316. async submitForm() {
  317. this.$refs["form"].validate(async (valid) => {
  318. if (valid) {
  319. this.loading = true;
  320. try {
  321. let res = await addAssess(this.form);
  322. if (res.code === 200) {
  323. this.$modal.msgSuccess("保存成功");
  324. this.cancel();
  325. this.getList(this.queryParams);
  326. }
  327. } catch (err) {
  328. console.error(err);
  329. } finally {
  330. this.loading = false;
  331. }
  332. } else {
  333. return false;
  334. }
  335. });
  336. },
  337. // 取消按钮
  338. cancel() {
  339. this.open = false;
  340. this.reset();
  341. },
  342. getCurrentTime() {
  343. var date = new Date();//当前时间
  344. var year = date.getFullYear() //年
  345. var month = this.repair(date.getMonth() + 1);//月
  346. var day = this.repair(date.getDate());//日
  347. var hour = this.repair(date.getHours());//时
  348. var minute = this.repair(date.getMinutes());//分
  349. var second = this.repair(date.getSeconds());//秒
  350. //当前时间
  351. var curTime = year + "-" + month + "-" + day
  352. + " " + hour + ":" + minute + ":" + second;
  353. return curTime;
  354. },
  355. repair(i){
  356. if (i >= 0 && i <= 9) {
  357. return "0" + i;
  358. } else {
  359. return i;
  360. }
  361. },
  362. //获取当月
  363. getCurrentMonth(){
  364. const date = new Date()
  365. let year = date.getFullYear()
  366. let month = date.getMonth() + 1
  367. month = month > 9 ? month : '0' + month
  368. return `${year}-${month}`
  369. },
  370. },
  371. };
  372. </script>
  373. <style scoped lang="scss">
  374. .el-card {
  375. width: calc(100% - 20px);
  376. height: 100%;
  377. margin: 10px;
  378. padding: 20px;
  379. }
  380. .el-button-group + .el-button-group {
  381. margin: 0 0 0 10px;
  382. }
  383. .btn_grooup {
  384. margin-bottom: 10px;
  385. display: flex;
  386. justify-content: flex-end;
  387. }
  388. .el-pagination {
  389. margin-top: 10px;
  390. text-align: right;
  391. }
  392. </style>