index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  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="MK_CUSTOMER_BYPRINCIPAL"
  135. :dataMapping="{
  136. customer: 'id',
  137. customerName: 'name',
  138. }"
  139. :source.sync="form"
  140. :queryParams="additionalCondition"
  141. >
  142. </dr-popover-select>
  143. </el-form-item>
  144. </el-col>
  145. <el-col :span="1.5">
  146. <el-form-item label="创建日期" prop="createTime">
  147. <el-input
  148. v-model="form.createTime"
  149. style="width: 200px"
  150. clearable
  151. readonly
  152. />
  153. </el-form-item>
  154. </el-col>
  155. <el-col :span="1.5">
  156. <el-form-item label="创建人" prop="createByName">
  157. <el-input
  158. v-model="form.createByName"
  159. style="width: 200px"
  160. clearable
  161. readonly
  162. />
  163. </el-form-item>
  164. </el-col>
  165. <el-col :span="1.5">
  166. <el-form-item label="部门" prop="deptName">
  167. <el-input
  168. v-model="form.deptName"
  169. style="width: 200px"
  170. clearable
  171. readonly
  172. />
  173. </el-form-item>
  174. </el-col>
  175. </el-row>
  176. </el-form>
  177. <div slot="footer">
  178. <el-button type="primary" @click="submitForm">确 定</el-button>
  179. <el-button @click="cancel">取 消</el-button>
  180. </div>
  181. </el-dialog>
  182. </div>
  183. </template>
  184. <script>
  185. import Detail from './detail.vue'
  186. import { addAssess,listAssess,delAssess, } from "@/api/business/spd/fillin/dailysale_quantity_assess";
  187. import { byPrincipal } from "@/api/business/spd/bo/iuapquery/basic";
  188. export default {
  189. name: "dailysaleQuantityAssess",
  190. components: {Detail},
  191. data() {
  192. return {
  193. loading: false,
  194. // 是否显示弹出层
  195. open: false,
  196. //新增表单
  197. form: {
  198. month: "",
  199. customer: "",
  200. customerName: "",
  201. },
  202. //表单校验
  203. rules: {
  204. month: [{ required: true, message: "月份不能为空", trigger: "blur" }],
  205. customer: [
  206. { required: true, message: "客户不能为空", trigger: "blur" },
  207. ],
  208. },
  209. // 搜索框参数
  210. queryParams: {
  211. customerName:null,
  212. month:null,
  213. deptName:null,
  214. deptName:null,
  215. pageNum: 1,
  216. pageSize: 10,
  217. },
  218. //总条数
  219. total: 0,
  220. //列表数据
  221. tableList:[],
  222. //是否打开详情页面
  223. openDetail:false,
  224. //编辑页面打开方式,add或edit或see
  225. openMode:'',
  226. //行数据
  227. row:{},
  228. //查询员工所负责的客户
  229. queryCustomerParams:{
  230. staffCode:"",
  231. code:"",
  232. name:"",
  233. },
  234. customerList:[],
  235. };
  236. },
  237. async created() {
  238. await this.getList(this.queryParams);
  239. this.queryCustomerParams.staffCode = this.$store.state.user.name;
  240. await this.getCustomer();
  241. },
  242. methods: {
  243. //是否打开详情页面
  244. useOpenDetail(){
  245. this.openDetail = !this.openDetail;
  246. },
  247. //新增
  248. useAdd(){
  249. this.reset();
  250. if(this.customerList.length){
  251. this.form.customer = this.customerList[0].id;
  252. this.form.customerName = this.customerList[0].name;
  253. }
  254. this.form.createTime = this.getCurrentTime();
  255. this.form.month = this.getCurrentMonth();
  256. this.form.createByName = this.$store.state.user.nickName;
  257. this.form.dept = this.$store.state.user.deptId;
  258. this.form.deptName = this.$store.state.user.deptName;
  259. this.open = true;
  260. },
  261. //编辑
  262. async useEdit(row){
  263. this.openMode = 'edit';
  264. this.row = row;
  265. this.openDetail = true;
  266. },
  267. //删除
  268. async useDel(row){
  269. this.$modal.confirm('确认删除选择数据').then(() => {
  270. delAssess(row.id).then(res => {
  271. if (res.code === 200) {
  272. this.$modal.msgSuccess("删除成功");
  273. this.getList(this.queryParams);
  274. }
  275. })
  276. }).catch(() => {})
  277. },
  278. //查询列表
  279. async getList(params){
  280. this.loading = true;
  281. await listAssess(params).then(res => {
  282. if (res.code === 200) {
  283. this.tableList = res.rows
  284. this.total = res.total
  285. }
  286. this.loading = false;
  287. })
  288. },
  289. //查询客户
  290. async getCustomer(){
  291. await byPrincipal(this.queryCustomerParams).then(res => {
  292. if (res.code === 200) {
  293. this.customerList = res.rows
  294. this.queryCustomerParams.total = res.total
  295. }
  296. })
  297. },
  298. //客户弹窗附加查询条件
  299. additionalCondition(){
  300. return {
  301. parame:{
  302. staffCode: this.$store.state.user.name
  303. }
  304. }
  305. },
  306. //双击
  307. useDoubleClick(row){
  308. this.openMode = 'see';
  309. this.row = row;
  310. this.openDetail = true;
  311. },
  312. //改变一页显示条数
  313. useChangePageSize(val){
  314. this.queryParams.pageSize = val
  315. this.getList(this.queryParams)
  316. },
  317. //翻页
  318. useCurrentChange(val){
  319. this.queryParams.pageNum = val
  320. this.getList(this.queryParams)
  321. },
  322. //搜索
  323. useSearch() {
  324. console.log(this.queryParams);
  325. this.getList(this.queryParams);
  326. },
  327. //重置
  328. useReset(){
  329. this.queryParams = {
  330. customerName:null,
  331. month:null,
  332. deptName:null,
  333. deptName:null,
  334. pageNum: 1,
  335. pageSize: 10,
  336. }
  337. this.getList(this.queryParams);
  338. },
  339. //重置表单
  340. reset(){
  341. this.form = {
  342. month: "",
  343. customer: "",
  344. customerName: "",
  345. }
  346. },
  347. // 确认
  348. async submitForm() {
  349. this.$refs["form"].validate(async (valid) => {
  350. if (valid) {
  351. this.loading = true;
  352. try {
  353. let res = await addAssess(this.form);
  354. if (res.code === 200) {
  355. this.$modal.msgSuccess("保存成功");
  356. this.cancel();
  357. this.getList(this.queryParams);
  358. }
  359. } catch (err) {
  360. console.error(err);
  361. } finally {
  362. this.loading = false;
  363. }
  364. } else {
  365. return false;
  366. }
  367. });
  368. },
  369. // 取消按钮
  370. cancel() {
  371. this.open = false;
  372. this.reset();
  373. },
  374. getCurrentTime() {
  375. var date = new Date();//当前时间
  376. var year = date.getFullYear() //年
  377. var month = this.repair(date.getMonth() + 1);//月
  378. var day = this.repair(date.getDate());//日
  379. var hour = this.repair(date.getHours());//时
  380. var minute = this.repair(date.getMinutes());//分
  381. var second = this.repair(date.getSeconds());//秒
  382. //当前时间
  383. var curTime = year + "-" + month + "-" + day
  384. + " " + hour + ":" + minute + ":" + second;
  385. return curTime;
  386. },
  387. repair(i){
  388. if (i >= 0 && i <= 9) {
  389. return "0" + i;
  390. } else {
  391. return i;
  392. }
  393. },
  394. //获取当月
  395. getCurrentMonth(){
  396. const date = new Date()
  397. let year = date.getFullYear()
  398. let month = date.getMonth() + 1
  399. month = month > 9 ? month : '0' + month
  400. return `${year}-${month}`
  401. },
  402. },
  403. };
  404. </script>
  405. <style scoped lang="scss">
  406. .el-card {
  407. width: calc(100% - 20px);
  408. height: 100%;
  409. margin: 10px;
  410. padding: 20px;
  411. }
  412. .el-button-group + .el-button-group {
  413. margin: 0 0 0 10px;
  414. }
  415. .btn_grooup {
  416. margin-bottom: 10px;
  417. display: flex;
  418. justify-content: flex-end;
  419. }
  420. .el-pagination {
  421. margin-top: 10px;
  422. text-align: right;
  423. }
  424. </style>