add.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <template>
  2. <div>
  3. <el-button type="primary" size="small" @click="dialogTableVisible = true">新 建</el-button>
  4. <el-dialog
  5. title="新建人员目标年度"
  6. :visible.sync="dialogTableVisible"
  7. width="370px"
  8. append-to-body
  9. @close="onCancel"
  10. >
  11. <div class="panel_Target">
  12. <el-row style="margin-top: 3%">
  13. <el-col :span="4" :offset="1">
  14. <div style="width: 100%;text-align: right">
  15. <label class="normal-margin inline-16" style="margin-top: 8%">年度:</label>
  16. </div>
  17. </el-col>
  18. <el-col :span="18">
  19. <el-date-picker
  20. style=" width: 100%;"
  21. class="normal-margin inline"
  22. v-model="form.year"
  23. type="year"
  24. value-format="yyyy"
  25. placeholder="选择要创建的年度"
  26. :clearable="false"
  27. size="small"
  28. :picker-options="pickerOptions">
  29. </el-date-picker>
  30. </el-col>
  31. </el-row>
  32. </div>
  33. <div class="dialog-footer ">
  34. <el-button size="small" @click="onCancel" class="normal-btn-width">取 消</el-button>
  35. <el-button size="small" type="primary" @click="onSubmit" class="normal-btn-width">确 定</el-button>
  36. </div>
  37. </el-dialog>
  38. <!-- <el-drawer
  39. title="新建目标"
  40. append-to-body
  41. :visible.sync="dialogTableVisible"
  42. size="60%"
  43. direction="rtl"
  44. @close="dialogTableVisible = false">
  45. <div class="drawer__panel">
  46. <p class="normal-margin inline-16" >年度:</p>
  47. <el-date-picker
  48. class="normal-margin"
  49. v-model="form.year"
  50. type="year"
  51. value-format="yyyy"
  52. placeholder="选择年"
  53. size="small">
  54. </el-date-picker>
  55. <div class="flex-align-center normal-margin flex-between">
  56. <p>请选择人员:</p>
  57. <div class="flex-align-center">
  58. <p>搜索:&nbsp;</p>
  59. <el-input style="width:250px" size="small" placeholder="人员姓名" v-model="condition" @keyup.native.enter="listData(params.content.pageNumber=1)" @clear="listData(params.content.pageNumber=1)" clearable></el-input>
  60. </div>
  61. </div>
  62. <tablelayout class="normal-margin" :layout="tablecols" :data="list" :custom="true" :checkbox="true" height="calc(100vh - 452px)" @checkboxCallBack="checkboxCallBack">
  63. <template v-slot:customcol="scope">
  64. <p>{{scope.column.data[scope.column.columnname]}}</p>
  65. </template>
  66. </tablelayout>
  67. &lt;!&ndash; <el-pagination
  68. background
  69. small
  70. @size-change="handleSizeChange"
  71. @current-change="handleCurrentChange"
  72. :current-page="params.content.pageNumber"
  73. :page-size="params.content.pageSize"
  74. layout="total, prev, pager, next, jumper"
  75. :total="total">
  76. </el-pagination> &ndash;&gt;
  77. <div class="flex-align-center">
  78. <p>已选{{selection.length}}人</p>&nbsp;
  79. <p>总共{{list.length}}人</p>
  80. </div>
  81. <div class="dialog-footer fixed__btn__panel">
  82. <el-button size="small" @click="dialogTableVisible = false" class="normal-btn-width">取 消</el-button>
  83. <el-button size="small" type="primary" :disabled="selection.length === 0" @click="onSubmit" class="normal-btn-width">确 定</el-button>
  84. </div>
  85. </div>
  86. </el-drawer>-->
  87. </div>
  88. </template>
  89. <script>
  90. import tablelayout from '@/components/table/index.vue'
  91. export default {
  92. components:{
  93. tablelayout
  94. },
  95. data () {
  96. let that = this
  97. return {
  98. pickerOptions:{
  99. disabledDate(time){
  100. /*console.log(that.yearOpens,'已经开启的年份')*/
  101. /* return time.getFullYear() < new Date().getFullYear()*/
  102. /*const timestamp = time.getTime(); // 将待比较的日期转换成时间戳格式*/
  103. for (var i = 0;i<that.yearOpens.length;i++) {
  104. /*const disabledTimestamp = new Date(date).getTime(); // 将禁用日期转换成时间戳格式*/
  105. if (time.getFullYear() < new Date().getFullYear() || time.getFullYear() === that.yearOpens[i].year) {
  106. return true; // 禁用日期
  107. }
  108. }
  109. return false; // 可选日期
  110. }
  111. },
  112. yearOpens:[],
  113. dialogTableVisible:false,
  114. form:{
  115. "year": '',
  116. "sa_salestargetbillid": 0,//新建年度是为0,添加人员时为具体的数据id
  117. "sales":[]
  118. },
  119. tablecols:[],
  120. list:[],
  121. selection:[],
  122. condition:'',
  123. total:0,
  124. params: {
  125. "id": 20220901091302,
  126. "content": {
  127. "pageNumber":1,
  128. "pageSize":20,
  129. "sa_salestargetbillid": 1,
  130. "where": {
  131. "condition": ""
  132. }
  133. },
  134. }
  135. }
  136. },
  137. methods:{
  138. /*handleSizeChange(val) {
  139. // console.log(`每页 ${val} 条`);
  140. this.params.content.pageSize = val
  141. this.listData()
  142. },
  143. handleCurrentChange(val) {
  144. // console.log(`当前页: ${val}`);
  145. this.params.content.pageNumber = val
  146. this.listData()
  147. },*/
  148. /*async listData () {
  149. this.params.content.where.condition = this.condition
  150. const res = await this.$api.requested(this.params)
  151. this.total = res.total
  152. res.data.forEach(e => {
  153. e.marea = e.area.map(m=>{
  154. return `${m.province}${m.city}${m.county}`
  155. })
  156. e.marea = e.marea.join(',')
  157. });
  158. this.list = res.data
  159. },
  160. checkboxCallBack (val) {
  161. this.selection = val
  162. },*/
  163. async onSubmit () {
  164. /*if (this.form.year === '') return this.$message({
  165. message:'请选择年度',
  166. type:'error'
  167. })*/
  168. const res = await this.$api.requested({
  169. "id": 20220831165302,
  170. "content": {
  171. "year":this.form.year,
  172. "sa_salestargetbillid": 0,
  173. "sales": this.selection
  174. },
  175. })
  176. this.tool.showMessage(res,()=>{
  177. this.dialogTableVisible = false
  178. this.form = {
  179. "year": '',
  180. "sa_salestargetbillid": 0,//新建年度是为0,添加人员时为具体的数据id
  181. "sales":[]
  182. }
  183. this.yearData()
  184. this.$emit('onSuccess')
  185. })
  186. },
  187. onCancel(){
  188. this.form = {
  189. "year": '',
  190. "sa_salestargetbillid": 0,//新建年度是为0,添加人员时为具体的数据id
  191. "sales":[]
  192. }
  193. this.yearData()
  194. this.dialogTableVisible = false
  195. },
  196. /*获取默认年度*/
  197. yearData(){
  198. const nowDate = new Date()
  199. console.log(nowDate.getFullYear())
  200. this.form.year = String(nowDate.getFullYear() + 1)
  201. },
  202. /*已开启年度*/
  203. async yearList(){
  204. const res = await this.$api.requested({
  205. "id": 20230728090204,
  206. "content": {
  207. "type": 1,
  208. "targettype": "人员目标"
  209. },
  210. })
  211. this.yearOpens = res.data
  212. },
  213. /*pickerOptions(){
  214. // return time.getTime() < Date.now(); //当天不可选
  215. const time = new Date()
  216. return time.getFullYear() < new Date().getFullYear(); // - 86400000是否包括当天
  217. }*/
  218. },
  219. mounted () {
  220. /*this.listData()*/
  221. this.yearData()
  222. this.yearList()
  223. },
  224. created () {
  225. this.tablecols = this.tool.tabelCol(this.$route.name)['personalTable'].tablecols
  226. }
  227. }
  228. </script>
  229. <style scoped>
  230. .el-pagination {
  231. text-align: right;
  232. }
  233. .panel_Target {
  234. border-top:1px solid #eeeeee;
  235. padding:5px 5px;
  236. margin-bottom:0px
  237. }
  238. >>> .el-dialog__body {
  239. padding: 0px 0px 10px;
  240. color: #606266;
  241. font-size: 14px;
  242. word-break: break-all;
  243. }
  244. >>> .el-dialog__header {
  245. padding: 10px 10px 10px ;
  246. }
  247. .dialog-footer{
  248. margin-top: 0px;
  249. margin-bottom: 10px;
  250. }
  251. >>> .el-dialog__title {
  252. line-height: 24px;
  253. font-size: 16px;
  254. color: #303133;
  255. }
  256. </style>