edit copy.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. <template>
  2. <div>
  3. <el-button size="mini" type="primary" @click="onShow(drawer = true)">编 辑</el-button>
  4. <el-drawer
  5. title="我是标题"
  6. :visible.sync="drawer"
  7. direction="rtl"
  8. append-to-body
  9. size="80%">
  10. <div class="drawer__panel">
  11. <el-row :gutter="20">
  12. <el-form :model="form" class="demo-form-inline" size="small" label-position="rigth" label-width="90px">
  13. <el-col :span="20">
  14. <el-form-item style="width:100%" label="工作任务">
  15. <el-input style="width:100%" v-model="form.taskname" placeholder="输入工作任务"></el-input>
  16. </el-form-item>
  17. </el-col>
  18. <el-col :span="4">
  19. <el-form-item label="排序">
  20. <el-input v-model="form.sequence"></el-input>
  21. </el-form-item>
  22. </el-col>
  23. <el-col :span="24">
  24. <el-form-item label="关键任务">
  25. <el-radio-group class="inline-16" v-model="form.important">
  26. <el-radio :label="1">是</el-radio>
  27. <el-radio :label="0">否</el-radio>
  28. </el-radio-group>
  29. <div class="inline-16">
  30. <el-checkbox disabled v-model="form.onparties" :true-label="1" :false-label="0" @change="onPartiesChange">关联客户对象</el-checkbox>
  31. <!-- <AssociateCustomerObject ref="onparties" :data="form" class="inline-16" style="margin-left: 10px" @selectObject="selectObject"></AssociateCustomerObject> -->
  32. </div>
  33. <div class="inline-16">
  34. <el-checkbox disabled v-model="form.onstage" :true-label="1" :false-label="0" style="font-size: 14px" @change="onOnstageChange">关联项目阶段</el-checkbox>
  35. <!-- <AssociatedProjectPhases ref="onstage" :data="form" class="inline-16" style="margin-left: 10px" @selectStage="selectStage"></AssociatedProjectPhases> -->
  36. </div>
  37. </el-form-item>
  38. </el-col>
  39. </el-form>
  40. </el-row>
  41. <div class="normal-margin">
  42. <div class="normal-margin flex-align-center flex-between">
  43. <p class="normal-title">评估项</p>
  44. <!-- <el-button type="primary" size="small" @click="addOptions">添加任务</el-button> -->
  45. </div>
  46. <el-table
  47. :data="form.projtaskmag_options"
  48. style="width: 100%"
  49. @row-click="rowClick"
  50. :row-class-name="tableRowClassName"
  51. highlight-current-row
  52. border>
  53. <el-table-column
  54. type="index"
  55. width="50">
  56. </el-table-column>
  57. <el-table-column
  58. prop="optionname"
  59. label="任务内容"
  60. width="360">
  61. <template slot-scope="scope">
  62. <el-input v-model="scope.row.optionname" placeholder=""></el-input>
  63. </template>
  64. </el-table-column>
  65. <el-table-column
  66. prop="remarks"
  67. label="描述"
  68. width="0">
  69. <template slot-scope="scope">
  70. <el-input v-model="scope.row.remarks" placeholder=""></el-input>
  71. </template>
  72. </el-table-column>
  73. <el-table-column
  74. prop="score"
  75. width="160"
  76. label="独立项分值">
  77. <template slot-scope="scope">
  78. <el-input v-model="scope.row.score" placeholder=""></el-input>
  79. </template>
  80. </el-table-column>
  81. <el-table-column
  82. prop="operation"
  83. width="100"
  84. label="操作">
  85. <template slot-scope="scope">
  86. <el-button type="text" size="mini" :disabled="form.projtaskmag_options.length === 1" @click="deleteOption(scope.$index)">删除</el-button>
  87. </template>
  88. </el-table-column>
  89. </el-table>
  90. </div>
  91. <div>
  92. <p class="normal-title normal-margin">关联设置({{activeOptions}})</p>
  93. <el-table
  94. :data="optionscore"
  95. border
  96. style="width: 100%">
  97. <el-table-column
  98. v-if="form.onparties"
  99. prop="partiestype"
  100. label="客户对象"
  101. >
  102. </el-table-column>
  103. <el-table-column
  104. v-if="form.onstage"
  105. prop="stagename"
  106. label="项目阶段"
  107. >
  108. </el-table-column>
  109. <el-table-column
  110. prop="score"
  111. label="分值">
  112. <template slot-scope="scope">
  113. <el-input v-model="scope.row.score" placeholder="" @change="onScoreChange"></el-input>
  114. <!-- <input type="text" v-model="scope.row.score" @input="onScoreChange"> -->
  115. </template>
  116. </el-table-column>
  117. </el-table>
  118. </div>
  119. </div>
  120. <div class="fixed__btn__panel">
  121. <el-button size="small" @click="drawer = false" class="normal-btn-width">取 消</el-button>
  122. <el-button size="small" type="primary" @click="onSubmit" class="normal-btn-width">确 定</el-button>
  123. </div>
  124. </el-drawer>
  125. </div>
  126. </template>
  127. <script>
  128. import AssociateCustomerObject from '@/HDrpManagement/projectTask/modules/AssociateCustomerObject.vue'
  129. import AssociatedProjectPhases from '@/HDrpManagement/projectTask/modules/AssociatedProjectStage.vue'
  130. export default {
  131. components:{
  132. AssociateCustomerObject,
  133. AssociatedProjectPhases
  134. },
  135. data () {
  136. return {
  137. drawer:false,
  138. show:true,
  139. form:{
  140. "sa_projtaskmagid": 0,
  141. "taskname": "",
  142. "sequence": 0,
  143. "important": 0,
  144. "onparties": 0,
  145. "onstage": 0,
  146. "projtaskmag_options": []
  147. },
  148. oldData:[],
  149. oldStage:[],
  150. optionscore:[],
  151. optionscoreStr:'',
  152. n_index:null,
  153. activeOptions:null
  154. }
  155. },
  156. methods:{
  157. onShow () {
  158. this.queryData()
  159. },
  160. async queryData () {
  161. const res = await this.$api.requested({
  162. "id": 20221128144104,
  163. "content": {
  164. "sa_projtaskmagid":this.$route.query.id
  165. }
  166. })
  167. this.form = res.data
  168. },
  169. selectObject (val) {
  170. this.oldData = val
  171. if (val.length === 0) {
  172. this.form.onparties = 0
  173. } else {
  174. if (this.oldStage.length > 0) {
  175. let arr = []
  176. this.oldData.forEach(e=>{
  177. this.oldStage.forEach(vl=>{
  178. arr.push({
  179. sa_projtaskmag_optionscoreid:0,
  180. partiestype:e.partiestype,
  181. stagename:vl.stagename,
  182. sa_projstagemagid:vl.sa_projstagemagid,
  183. score:0
  184. })
  185. })
  186. })
  187. this.optionscore = arr.sort()
  188. } else {
  189. this.optionscore = val
  190. }
  191. }
  192. },
  193. selectStage (val) {
  194. this.oldStage = val
  195. if (val.length === 0) {
  196. this.form.onstage = 0
  197. } else {
  198. if (this.oldData.length > 0) {
  199. let arr = []
  200. this.oldData.forEach(e=>{
  201. this.oldStage.forEach(vl=>{
  202. arr.push({
  203. sa_projtaskmag_optionscoreid:0,
  204. partiestype:e.partiestype,
  205. stagename:vl.stagename,
  206. sa_projstagemagid:vl.sa_projstagemagid,
  207. score:0
  208. })
  209. })
  210. })
  211. this.optionscore = arr.sort()
  212. } else {
  213. this.optionscore = val
  214. }
  215. }
  216. },
  217. rowClick (row, column, event) {
  218. try {
  219. this.n_index = row.index
  220. this.activeOptions = this.form.projtaskmag_options[this.n_index].optionname
  221. this.optionscore = this.form.projtaskmag_options[row.index].projtaskmag_optionscore
  222. } catch (error) {
  223. }
  224. },
  225. onScoreChange (row) {
  226. if (!this.activeOptions) return this.$message({
  227. message:'请先点击要设置的任务行',
  228. type:'error'
  229. })
  230. this.form.projtaskmag_options[this.n_index].projtaskmag_optionscore = this.optionscore
  231. },
  232. arraySpanMethod({ row, column, rowIndex, columnIndex }) {
  233. // 合并行列产品名字相同合并(计算组长度以内的列,需要进行合并操作的列)
  234. let mergeLength = 1;//需要进行横纵合并的列
  235. if (columnIndex < mergeLength) {
  236. let finArray = [1,1];
  237. // 处理行数据
  238. let cgname = Object.keys(row)[columnIndex]
  239. console.log(cgname,'---')
  240. // let cgname = 'value'
  241. if(rowIndex === 0 || row[cgname] !== this.optionscore[rowIndex-1][cgname]){
  242. let rowspan = 1;
  243. //计算需要进行合并操作的行
  244. for(let i=0; i<this.optionscore.length-1; i++){
  245. // 只合并连续的
  246. if(this.optionscore[i][cgname] === row[cgname] && this.optionscore[i+1][cgname] === row[cgname]){
  247. rowspan ++;
  248. }
  249. }
  250. finArray[0] = rowspan;
  251. }else {
  252. finArray[0] = 0;
  253. }
  254. // 处理列数据
  255. let colkeys = Object.keys(row);
  256. let cgvalue = Object.values(row)[columnIndex]
  257. if(columnIndex ===0 || row[colkeys[columnIndex-1]] !== row[colkeys[columnIndex]]){
  258. let colspan = 1;
  259. //计算需要进行合并操作的列
  260. for(let i=columnIndex; i<mergeLength; i++) {
  261. // 只合并连续的
  262. if (row[colkeys[i]]===cgvalue && row[colkeys[i+1]]===cgvalue && i+1<mergeLength) {
  263. colspan ++;
  264. }
  265. }
  266. finArray[1] = colspan;
  267. } else {
  268. finArray[1] = 0;
  269. }
  270. return finArray
  271. }
  272. },
  273. refreshTable() {
  274. this.show = false
  275. setTimeout(() => {
  276. this.show = true
  277. }, 1000);
  278. },
  279. onPartiesChange (val) {
  280. if (val === 1) {
  281. let arr = []
  282. this.$refs.onparties.drawer = true
  283. this.optionscore = arr.sort()
  284. } else {
  285. this.oldData = []
  286. const res = new Map();
  287. this.optionscore = this.optionscore.filter((item) => !res.has(item['stagename']) && res.set(item['stagename'], 1));
  288. this.form.projtaskmag_options.forEach(e=>{
  289. e.projtaskmag_optionscore = this.optionscore
  290. })
  291. }
  292. },
  293. onOnstageChange (val) {
  294. if (val === 1) {
  295. this.$refs.onstage.drawer = true
  296. } else {
  297. this.oldStage = []
  298. const res = new Map();
  299. this.optionscore = this.optionscore.filter((item) => !res.has(item['partiestype']) && res.set(item['partiestype'], 1));
  300. this.form.projtaskmag_options.forEach(e=>{
  301. e.projtaskmag_optionscore = this.optionscore
  302. })
  303. }
  304. },
  305. tableRowClassName({row,rowIndex}) {
  306. row.index = rowIndex
  307. },
  308. addOptions(){
  309. this.form.projtaskmag_options.push({
  310. "sa_projtaskmag_optionsid": 0,
  311. "optionname": "",
  312. "remarks": "",
  313. "score": 0,
  314. "projtaskmag_optionscore": {
  315. "sa_projtaskmag_optionscoreid":0,
  316. "partiestype": "",
  317. "sa_projstagemagid": "",
  318. "score": 0
  319. }
  320. })
  321. },
  322. async onSubmit () {
  323. const res = await this.$api.requested({
  324. "id": "20221128144204",
  325. "content":this.form
  326. })
  327. this.tool.showMessage(res,()=>{
  328. this.$emit('onSuccess')
  329. this.drawer = false
  330. })
  331. },
  332. deleteOption (index) {
  333. this.form.projtaskmag_options = this.form.projtaskmag_options.filter((e,idx)=>{
  334. if (index !== idx) return e
  335. })
  336. this.activeOptions = ''
  337. console.log(this.form.projtaskmag_options)
  338. }
  339. }
  340. }
  341. </script>