You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1011 lines
34 KiB

1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
11 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
11 months ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
1 year ago
12 months ago
1 year ago
11 months ago
1 year ago
12 months ago
1 year ago
12 months ago
12 months ago
12 months ago
4 weeks ago
12 months ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
11 months ago
1 year ago
12 months ago
1 year ago
10 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
  1. <template>
  2. <div>
  3. <div style="width: 1000px">
  4. <el-form :model="templateQuery" ref="queryForm" label-position="top">
  5. <el-row :gutter="10">
  6. <el-col :span="4">
  7. <el-form-item label="模板编码" prop="codeNo">
  8. <el-input v-model="templateQuery.codeNo" clearable></el-input>
  9. </el-form-item>
  10. </el-col>
  11. <el-col :span="4">
  12. <el-form-item label="模板描述" prop="codeDesc">
  13. <el-input v-model="templateQuery.codeDesc" clearable></el-input>
  14. </el-form-item>
  15. </el-col>
  16. <el-col :span="4">
  17. <el-form-item label="模板分组" prop="functionType">
  18. <el-select v-model="templateQuery.functionType" placeholder="模板分组" clearable style="width: 100%;">
  19. <el-option label="全部" value=""></el-option>
  20. <el-option v-for="dict in dict.type.function_type_desc" :key="dict.value" :label="dict.label"
  21. :value="dict.value" />
  22. </el-select>
  23. </el-form-item>
  24. </el-col>
  25. <el-col :span="4">
  26. <el-form-item label="状态" prop="active">
  27. <el-select v-model="templateQuery.active">
  28. <el-option label="全部" value=""></el-option>
  29. <el-option label="启用" value="Y"></el-option>
  30. <el-option label="停用" value="N"></el-option>
  31. </el-select>
  32. </el-form-item>
  33. </el-col>
  34. <el-col :span="6">
  35. <el-form-item label=" ">
  36. <el-button type="primary" @click="handleQueryByPage">查询</el-button>
  37. <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
  38. <el-button type="primary" @click="handleSave(null)">新增</el-button>
  39. </el-form-item>
  40. </el-col>
  41. </el-row>
  42. </el-form>
  43. </div>
  44. <el-table :data="dataList" v-loading="queryLoading" border style="width: 100%;margin-top: 5px" height="80vh">
  45. <el-table-column v-for="(item,index) in columns" :key="index" :sortable="item.columnSortable"
  46. :prop="item.columnProp" :header-align="item.headerAlign" :show-overflow-tooltip="item.showOverflowTooltip"
  47. :align="item.align" :fixed="item.fixed==''?false:item.fixed" :min-width="item.columnWidth"
  48. :label="item.columnLabel">
  49. <template slot-scope="scope">
  50. <div v-if="item.columnProp !== 'active' && item.columnProp !== 'functionType'">
  51. <span v-if="!item.columnHidden">{{ scope.row[scope.column.property] }}</span>
  52. <span v-if="item.columnImage"><img :src="scope.row[scope.column.property]"
  53. style="width: 100px; height: 80px" /></span>
  54. </div>
  55. <dict-tag v-else-if="item.columnProp == 'functionType'" :options="dict.type.function_type_desc"
  56. :value="scope.row.functionType" />
  57. <span v-else
  58. :style="{color:scope.row.active === 'Y'?'#67C23A':'red'}">{{ scope.row.active === 'Y' ? '启用' : '停用' }}</span>
  59. </template>
  60. </el-table-column>
  61. <el-table-column header-align="center" fixed="right" align="center" width="160" label="操作">
  62. <template slot-scope="scope">
  63. <el-link style="cursor: pointer" @click="handleSave(scope.row)">编辑</el-link>
  64. <el-link style="cursor: pointer" @click="handleRemove(scope.row)">删除</el-link>
  65. <el-link style="cursor: pointer" @click="handleItem(scope.row)">属性项目</el-link>
  66. </template>
  67. </el-table-column>
  68. </el-table>
  69. <el-pagination @size-change="handleSizeChange" @current-change="handlePageChange" :current-page="pageIndex"
  70. :page-sizes="[20, 50, 100, 200, 500]" :page-size="pageSize" :total="total"
  71. layout="total,sizes, prev, pager, next, jumper">
  72. </el-pagination>
  73. <!-- /*属性模板弹框 */ -->
  74. <el-dialog title="属性模板" :close-on-click-modal="false" v-drag :visible.sync="saveVisible" width="400px">
  75. <el-form :model="saveForm" ref="saveForm" :rules="rules" label-position="top" label-width="100px">
  76. <el-row :gutter="10">
  77. <el-col :span="12">
  78. <el-form-item label="工厂" prop="site" :show-message="false">
  79. <el-select v-model="saveForm.site" style="width: 100%">
  80. <el-option v-for="(item,index) in userSiteList" :key="index" :label="item.deptName"
  81. :value="item.deptId">
  82. </el-option>
  83. </el-select>
  84. </el-form-item>
  85. </el-col>
  86. <!-- </el-row>
  87. <el-row :gutter="10">
  88. <el-col :span="10">
  89. <el-form-item label="模板编码" prop="codeNo" :show-message="false">
  90. <el-input v-model="saveForm.codeNo" :disabled="saveForm.id > 0"></el-input>
  91. </el-form-item>
  92. </el-col> -->
  93. <el-col :span="12">
  94. <el-form-item label="模板描述" prop="codeDesc" :show-message="false">
  95. <el-input v-model="saveForm.codeDesc"></el-input>
  96. </el-form-item>
  97. </el-col>
  98. <el-col :span="10">
  99. <el-form-item label="模板分组" prop="functionType" :show-message="false">
  100. <el-select v-model="saveForm.functionType" style="width: 100%;">
  101. <el-option label="全部" value=""></el-option>
  102. <el-option v-for="dict in dict.type.function_type_desc" :key="dict.value" :label="dict.label"
  103. :value="dict.value" />
  104. </el-select>
  105. </el-form-item>
  106. </el-col>
  107. <el-col :span="14">
  108. <el-form-item label=" " :show-message="false" prop="active">
  109. <el-checkbox v-model="saveForm.active" true-label="Y" false-label="N">状态</el-checkbox>
  110. </el-form-item>
  111. </el-col>
  112. </el-row>
  113. </el-form>
  114. <div slot="footer" class="dialog-footer">
  115. <el-button type="primary" :loading="saveLoading" @click="handleSaveOrUpdate"> </el-button>
  116. <el-button @click="saveVisible = false"> </el-button>
  117. </div>
  118. </el-dialog>
  119. <!-- /*属性项目弹框*/ -->
  120. <el-dialog title="属性项目清单" :close-on-click-modal="false" v-drag :visible.sync="itemVisible" width="1000px">
  121. <el-form :model="propertyTemplateItem" label-position="top">
  122. <el-row :gutter="10">
  123. <el-col :span="4">
  124. <el-form-item label="属性模板编码">
  125. <el-input v-model="propertyTemplateItem.codeNo" disabled></el-input>
  126. </el-form-item>
  127. </el-col>
  128. <el-col :span="6">
  129. <el-form-item label="属性模板名称">
  130. <el-input v-model="propertyTemplateItem.codeDesc" disabled></el-input>
  131. </el-form-item>
  132. </el-col>
  133. <el-col :span="4">
  134. <el-form-item label=" ">
  135. <el-button type="primary" @click="handleSaveItem(null)">新增</el-button>
  136. </el-form-item>
  137. </el-col>
  138. </el-row>
  139. </el-form>
  140. <el-table :height="300" :data="itemList2" border style="width: 100%;" class="itemListClass"
  141. :loading="itemListLoading">
  142. <el-table-column header-align="center" align="left" width="70" label="排序">
  143. <template slot-scope="scope">
  144. <el-link style="cursor: pointer" @click="updateItemSort(scope.row,scope.$index,-1)"
  145. v-if="scope.$index !== 0">上移</el-link>
  146. <el-link style="cursor: pointer" @click="updateItemSort(scope.row,scope.$index,1)"
  147. v-if="scope.$index < itemList2.length-1">下移</el-link>
  148. </template>
  149. </el-table-column>
  150. <el-table-column v-for="(item,index) in columnDetailList" :key="index" :sortable="item.columnSortable"
  151. :prop="item.columnProp" :header-align="item.headerAlign" :show-overflow-tooltip="item.showOverflowTooltip"
  152. :align="item.align" :fixed="item.fixed==''?false:item.fixed" :min-width="item.columnWidth"
  153. :label="item.columnLabel">
  154. <template slot-scope="scope">
  155. <span v-if="!item.columnHidden">
  156. <!-- <template
  157. v-if="item.columnProp==='valueType'">{{ scope.row[item.columnProp] === 'text' ? '文本' : '数字' }}</template>
  158. <template
  159. v-else-if="item.columnProp==='valueChooseFlag'">{{ scope.row[item.columnProp] === 'Y' ? '是' : '否' }}</template>
  160. <template v-else>{{ scope.row[item.columnProp] }}</template> -->
  161. <template v-if="item.columnProp==='daysNumber'">
  162. <el-input :controls="false" :ref="`daysNumber${scope.$index}`" v-model="scope.row.daysNumber"
  163. @keyup.enter.native="focusNextInput(scope.$index, 'daysNumber')"
  164. style="height: 11px; width: 98%;"></el-input>
  165. </template>
  166. <template v-else-if="item.columnProp==='ismainFlag'">
  167. <el-switch style="height: 15px; width: 50px;margin-top: -2px;" :ref="`ismainFlag${scope.$index}`"
  168. v-model="scope.row.ismainFlag" active-value="Y" inactive-value="N"
  169. @keyup.enter.native="focusNextInput(scope.$index, 'ismainFlag')" active-color="#13ce66"
  170. inactive-color="#ff4949"></el-switch>
  171. </template>
  172. <template v-else-if="item.columnProp==='roleId'">
  173. <el-select v-model="scope.row.roleId" :ref="`roleId${scope.$index}`" placeholder="请选择">
  174. <el-option v-for="(item,index) in roleIdList " :key="index" :label="item.roleName"
  175. :value="item.roleId">
  176. </el-option>
  177. </el-select>
  178. </template>
  179. <template v-else>{{ scope.row[item.columnProp] }}</template>
  180. </span>
  181. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
  182. style="width: 100px; height: 80px" /></span>
  183. </template>
  184. </el-table-column>
  185. <el-table-column header-align="center" align="center" width="130" label="操作">
  186. <template slot-scope="scope">
  187. <a v-if="scope.row.valueChooseFlag === 'Y'" @click="handleChooseValue(scope.row)">可选值</a>
  188. <a @click="handleRemoveItem(scope.row)">删除属性</a>
  189. </template>
  190. </el-table-column>
  191. </el-table>
  192. <div slot="footer" class="dialog-footer">
  193. <el-button type="primary" :loading="itemListLoading" @click="itemListBatchSave"> </el-button>
  194. <el-button type="primary" @click="itemVisible = false"> </el-button>
  195. </div>
  196. </el-dialog>
  197. <!-- /*添加模板属性弹框 */ -->
  198. <el-dialog title="新增属性" :close-on-click-modal="false" v-drag :visible.sync="itemSaveVisible" width="1000px">
  199. <div style="font-size: 12px">
  200. <el-form label-position="top" :model="item">
  201. <el-row :gutter="10">
  202. <el-col :span="3">
  203. <el-form-item label="属性编码">
  204. <el-input v-model="item.itemNo"></el-input>
  205. </el-form-item>
  206. </el-col>
  207. <el-col :span="3">
  208. <el-form-item label="属性名称">
  209. <el-input v-model="item.itemDesc"></el-input>
  210. </el-form-item>
  211. </el-col>
  212. <el-col :span="3">
  213. <el-form-item label=" ">
  214. <el-button type="primary" @click="handleQueryItem">查询</el-button>
  215. </el-form-item>
  216. </el-col>
  217. </el-row>
  218. </el-form>
  219. </div>
  220. <el-container style="margin-top: 0px;">
  221. <el-main style="width: 350px;padding: 1px">
  222. <span style="font-size: 12px">可选属性</span>
  223. <el-table height="400px" :data="itemList1" border @selection-change="selectionItem1"
  224. @row-click="handleRowClick1" ref="itemTable1" style="width: 100%">
  225. <el-table-column type="selection" header-align="center" align="center" width="50">
  226. </el-table-column>
  227. <el-table-column prop="itemNo" header-align="center" align="center" min-width="80" label="属性编码">
  228. </el-table-column>
  229. <el-table-column prop="itemDesc" header-align="center" align="center" min-width="200" label="属性名称">
  230. </el-table-column>
  231. </el-table>
  232. </el-main>
  233. <el-main style="width: 10px;padding: 1px">
  234. <div style="margin-top: 200px;margin-left: 18px">
  235. <el-button type="primary" @click="handleAddItem">添加>></el-button>
  236. </div>
  237. <div style="margin-top: 15px;margin-left: 18px">
  238. <el-button type="primary" @click="handleRemoveBatchItem">&lt;&lt;删除</el-button>
  239. </div>
  240. </el-main>
  241. <el-main style="width: 350px;padding: 1px">
  242. <span style="font-size: 12px">已有属性</span>
  243. <el-table height="400px" border ref="itemTable2" @selection-change="selectionItem2"
  244. @row-click="handleRowClick2" :data="itemList2" style="width: 100%">
  245. <el-table-column type="selection" header-align="center" align="center" width="50">
  246. </el-table-column>
  247. <el-table-column prop="itemNo" header-align="center" align="center" min-width="80" label="属性编码">
  248. </el-table-column>
  249. <el-table-column prop="itemDesc" header-align="center" align="center" min-width="200" label="属性名称">
  250. </el-table-column>
  251. </el-table>
  252. </el-main>
  253. </el-container>
  254. <el-footer style="height:40px;margin-top: 20px;text-align:center">
  255. <el-button type="primary" @click="itemSaveVisible = false">关闭</el-button>
  256. </el-footer>
  257. </el-dialog>
  258. <el-dialog title="可选值" :close-on-click-modal="false" v-drag :visible.sync="valueChooseFlagVisible" width="500px">
  259. <el-form :model="availableForm" label-position="top">
  260. <el-row :gutter="10">
  261. <el-col :span="8">
  262. <el-form-item label="属性编码" prop="itemNo" :show-message="false">
  263. <el-input v-model="availableForm.itemNo" disabled></el-input>
  264. </el-form-item>
  265. </el-col>
  266. <el-col :span="10">
  267. <el-form-item label="属性描述" prop="itemDesc" :show-message="false">
  268. <el-input v-model="availableForm.itemDesc" disabled></el-input>
  269. </el-form-item>
  270. </el-col>
  271. </el-row>
  272. </el-form>
  273. <el-table :data="availableList" border style="width: 100%" :height="200">
  274. <el-table-column prop="availableValue" header-align="center" align="left" min-width="200" label="属性值">
  275. </el-table-column>
  276. </el-table>
  277. </el-dialog>
  278. </div>
  279. </template>
  280. <script>
  281. import { getSiteByUserName } from '@/api/dept.js'
  282. import { getRoleSelect } from '@/api/role.js'
  283. import {
  284. savePropertyTemplate,
  285. queryPropertyTemplateByPage,
  286. updatePropertyTemplate,
  287. queryPropertyTemplateDetail,
  288. queryPropertyTemplateDetailItem,
  289. batchSavePropertyTemplateDetail,
  290. batchUpdatePropertyTemplateDetail,
  291. removePropertyTemplateDetail,
  292. removeBatchPropertyTemplateDetail,
  293. removePropertyTemplate
  294. } from '@/api/property/property.js'
  295. export default {
  296. name: 'propertyTemplate',
  297. dicts: ['function_type_desc'],
  298. components: {},
  299. data() {
  300. return {
  301. pageIndex: 1,
  302. pageSize: 20,
  303. total: 0,
  304. menuId: 888001,
  305. dataList: [],
  306. roleIdList: [],
  307. queryLoading: false,
  308. itemListLoading: false,
  309. templateQuery: {
  310. codeNo: '',
  311. codeDesc: '',
  312. functionType: '',
  313. active: '',
  314. },
  315. userSiteList: [],
  316. saveVisible: false,
  317. saveLoading: false,
  318. columns: [
  319. {
  320. userId: this.$store.state.user.name,
  321. functionId: 888001,
  322. serialNumber: '180002TableFunctionTypeDesc',
  323. tableId: '180002Table',
  324. tableName: '属性项目表',
  325. columnProp: 'functionType',
  326. headerAlign: 'center',
  327. align: 'left',
  328. columnLabel: '模板分组',
  329. columnHidden: false,
  330. columnImage: false,
  331. columnSortable: false,
  332. sortLv: 0,
  333. status: true,
  334. fixed: '',
  335. },
  336. {
  337. userId: this.$store.state.user.name,
  338. functionId: 888001,
  339. serialNumber: '180002TableCodeNo',
  340. tableId: '180002Table',
  341. tableName: '属性模板表',
  342. columnProp: 'codeNo',
  343. headerAlign: 'center',
  344. align: 'center',
  345. columnLabel: '属性模板编码',
  346. columnHidden: false,
  347. columnImage: false,
  348. columnSortable: false,
  349. sortLv: 0,
  350. status: true,
  351. fixed: '',
  352. },
  353. {
  354. userId: this.$store.state.user.name,
  355. functionId: 888001,
  356. serialNumber: '180002TableCodeDesc',
  357. tableId: '180002Table',
  358. tableName: '属性模板表',
  359. columnProp: 'codeDesc',
  360. headerAlign: 'center',
  361. align: 'left',
  362. columnLabel: '属性模板描述',
  363. columnHidden: false,
  364. columnImage: false,
  365. columnSortable: false,
  366. sortLv: 0,
  367. status: true,
  368. fixed: '',
  369. columnWidth: 150,
  370. showOverflowTooltip: true,
  371. },
  372. {
  373. userId: this.$store.state.user.name,
  374. functionId: 888001,
  375. serialNumber: '180002TableActive',
  376. tableId: '180002Table',
  377. tableName: '属性模板表',
  378. columnProp: 'active',
  379. headerAlign: 'center',
  380. align: 'center',
  381. columnLabel: '状态',
  382. columnHidden: false,
  383. columnImage: false,
  384. columnSortable: false,
  385. sortLv: 0,
  386. status: true,
  387. fixed: '',
  388. },
  389. {
  390. userId: this.$store.state.user.name,
  391. functionId: 888001,
  392. serialNumber: '180002TableCreateDate',
  393. tableId: '180002Table',
  394. tableName: '属性模板表',
  395. columnProp: 'createDate',
  396. headerAlign: 'center',
  397. align: 'center',
  398. columnLabel: '创建时间',
  399. columnHidden: false,
  400. columnImage: false,
  401. columnSortable: false,
  402. columnWidth: 100,
  403. sortLv: 0,
  404. status: true,
  405. fixed: '',
  406. },
  407. {
  408. userId: this.$store.state.user.name,
  409. functionId: 888001,
  410. serialNumber: '180002TableCreateBy',
  411. tableId: '180002Table',
  412. tableName: '属性模板表',
  413. columnProp: 'createBy',
  414. headerAlign: 'center',
  415. align: 'left',
  416. columnLabel: '创建人',
  417. columnHidden: false,
  418. columnImage: false,
  419. columnSortable: false,
  420. sortLv: 0,
  421. status: true,
  422. fixed: '',
  423. columnWidth: 80,
  424. },
  425. {
  426. userId: this.$store.state.user.name,
  427. functionId: 888001,
  428. serialNumber: '180002TableUpdateDate',
  429. tableId: '180002Table',
  430. tableName: '属性模板表',
  431. columnProp: 'updateDate',
  432. headerAlign: 'center',
  433. align: 'center',
  434. columnLabel: '更新时间',
  435. columnHidden: false,
  436. columnImage: false,
  437. columnSortable: false,
  438. columnWidth: 100,
  439. sortLv: 0,
  440. status: true,
  441. fixed: '',
  442. },
  443. {
  444. userId: this.$store.state.user.name,
  445. functionId: 888001,
  446. serialNumber: '180002TableUpdateBy',
  447. tableId: '180002Table',
  448. tableName: '属性模板表',
  449. columnProp: 'updateBy',
  450. headerAlign: 'center',
  451. align: 'left',
  452. columnLabel: '更新人',
  453. columnHidden: false,
  454. columnImage: false,
  455. columnSortable: false,
  456. sortLv: 0,
  457. status: true,
  458. fixed: '',
  459. columnWidth: 80,
  460. },
  461. ],
  462. saveForm: {
  463. active: 'Y',
  464. },
  465. rules: {
  466. site: [{ required: true, message: '请选择site', trigger: 'change' }],
  467. codeNo: [
  468. { required: true, message: '请输入模板编码', trigger: 'blur' },
  469. ],
  470. codeDesc: [
  471. { required: true, message: '请输入模板描述', trigger: 'blur' },
  472. ],
  473. functionType: [
  474. { required: true, message: '请选择模板分组', trigger: 'change' },
  475. ],
  476. },
  477. propertyTemplateItem: {},
  478. itemVisible: false,
  479. detailList: [],
  480. columnDetailList: [
  481. {
  482. userId: this.$store.state.user.name,
  483. functionId: 180002,
  484. serialNumber: '180002Table2PropertiesItemNo',
  485. tableId: '180002Table2',
  486. tableName: '属性项目表',
  487. columnProp: 'propertiesItemNo',
  488. headerAlign: 'center',
  489. align: 'left',
  490. columnLabel: '属性项目编码',
  491. columnHidden: false,
  492. columnImage: false,
  493. columnSortable: false,
  494. sortLv: 0,
  495. status: true,
  496. fixed: '',
  497. columnWidth: 80,
  498. },
  499. {
  500. userId: this.$store.state.user.name,
  501. functionId: 180002,
  502. serialNumber: '180002Table2ItemDesc',
  503. tableId: '180002Table2',
  504. tableName: '属性项目表',
  505. columnProp: 'itemDesc',
  506. headerAlign: 'center',
  507. align: 'left',
  508. columnLabel: '属性项目名称',
  509. columnHidden: false,
  510. columnImage: false,
  511. columnSortable: false,
  512. sortLv: 0,
  513. status: true,
  514. fixed: '',
  515. },
  516. {
  517. userId: this.$store.state.user.name,
  518. functionId: 180002,
  519. serialNumber: '180002Table2ValueType',
  520. tableId: '180002Table2',
  521. tableName: '属性项目表',
  522. columnProp: 'daysNumber',
  523. headerAlign: 'center',
  524. align: 'center',
  525. columnLabel: '天数',
  526. columnHidden: false,
  527. columnImage: false,
  528. columnSortable: false,
  529. sortLv: 0,
  530. status: true,
  531. fixed: '',
  532. columnWidth: 60,
  533. },
  534. {
  535. userId: this.$store.state.user.name,
  536. functionId: 180002,
  537. serialNumber: '180002Table2DefaultValue',
  538. tableId: '180002Table2',
  539. tableName: '属性项目表',
  540. columnProp: 'ismainFlag',
  541. headerAlign: 'center',
  542. align: 'center',
  543. columnLabel: '是否关键事项',
  544. columnHidden: false,
  545. columnImage: false,
  546. columnSortable: false,
  547. sortLv: 0,
  548. status: true,
  549. fixed: '',
  550. columnWidth: 60,
  551. },
  552. {
  553. userId: this.$store.state.user.name,
  554. functionId: 180002,
  555. serialNumber: '180002Table2MaxValue',
  556. tableId: '180002Table2',
  557. tableName: '属性项目表',
  558. columnProp: 'roleId',
  559. headerAlign: 'center',
  560. align: 'center',
  561. columnLabel: '角色',
  562. columnHidden: false,
  563. columnImage: false,
  564. columnSortable: false,
  565. sortLv: 0,
  566. status: true,
  567. fixed: '',
  568. columnWidth: 70,
  569. },
  570. ],
  571. itemSaveVisible: false,
  572. item: {},
  573. selectionList1: [],
  574. selectionList2: [],
  575. itemList1: [],
  576. itemList2: [],
  577. valueChooseFlagVisible: false,
  578. availableForm: {},
  579. availableList: [],
  580. }
  581. },
  582. created() {
  583. this.handleQueryByPage()
  584. },
  585. watch: {},
  586. methods: {
  587. handleQueryByPage() {
  588. let params = {
  589. ...this.templateQuery,
  590. pageIndex: this.pageIndex,
  591. pageSize: this.pageSize,
  592. createBy: this.$store.state.user.name,
  593. }
  594. this.queryLoading = true
  595. queryPropertyTemplateByPage(params)
  596. .then(({ data }) => {
  597. if (data && data.code === 0) {
  598. this.dataList = data.page.records
  599. this.total = data.page.total
  600. this.pageIndex = data.page.current
  601. } else {
  602. this.$message.warning(data.msg)
  603. }
  604. this.queryLoading = false
  605. })
  606. .catch((error) => {
  607. this.$message.error(error)
  608. this.queryLoading = false
  609. })
  610. },
  611. handleSave(row) {
  612. this.getSiteByUserName()
  613. this.$nextTick(() => {
  614. if (this.$refs.saveForm) {
  615. this.$refs.saveForm.clearValidate()
  616. }
  617. })
  618. this.saveForm = JSON.parse(JSON.stringify(this.saveForm))
  619. if (row) {
  620. this.saveForm = {
  621. ...row,
  622. }
  623. } else {
  624. this.saveForm = JSON.parse(JSON.stringify({}))
  625. this.$set(this.saveForm,'active','Y')
  626. }
  627. this.saveVisible = true
  628. },
  629. handleSizeChange(val) {
  630. this.pageSize = val
  631. this.handleQueryByPage()
  632. },
  633. handlePageChange(val) {
  634. this.pageIndex = val
  635. this.handleQueryByPage()
  636. },
  637. handleSaveOrUpdate() {
  638. this.$refs.saveForm.validate((valid, obj) => {
  639. if (valid) {
  640. if (this.saveForm.id) {
  641. this.handleTemplateUpdate()
  642. } else {
  643. this.handleTemplateSave()
  644. }
  645. } else {
  646. let i = 1
  647. for (let key in obj) {
  648. if (i === 1) {
  649. this.$message.error(obj[key][0].message)
  650. break
  651. }
  652. i++
  653. }
  654. }
  655. })
  656. },
  657. handleTemplateUpdate() {
  658. let params = {
  659. ...this.saveForm,
  660. }
  661. this.saveLoading = true
  662. updatePropertyTemplate(params)
  663. .then(({ data }) => {
  664. this.saveLoading = false
  665. if (data && data.code === 0) {
  666. this.$message.success(data.msg)
  667. this.handleQueryByPage()
  668. this.saveVisible = false
  669. } else {
  670. this.$message.warning(data.msg)
  671. }
  672. })
  673. .catch((error) => {
  674. this.saveLoading = false
  675. this.$message.error(error)
  676. })
  677. },
  678. handleTemplateSave() {
  679. let params = {
  680. ...this.saveForm,
  681. }
  682. this.saveLoading = true
  683. savePropertyTemplate(params)
  684. .then(({ data }) => {
  685. this.saveLoading = false
  686. if (data && data.code === 0) {
  687. this.$message.success(data.msg)
  688. this.handleQueryByPage()
  689. this.saveVisible = false
  690. } else {
  691. this.$message.warning(data.msg)
  692. }
  693. })
  694. .catch((error) => {
  695. this.saveLoading = false
  696. this.$message.error(error)
  697. })
  698. },
  699. handleRemove(row) {
  700. this.$alert('确认删除该属性模板吗?', '提示', {
  701. confirmButtonText: '确定',
  702. cancelButtonText: '取消',
  703. type: 'warning',
  704. })
  705. .then(() => {
  706. let params = { ...row }
  707. removePropertyTemplate(params)
  708. .then(({ data }) => {
  709. if (data && data.code === 0) {
  710. this.$message.success(data.msg)
  711. this.handleQueryByPage()
  712. }
  713. })
  714. })
  715. .catch(() => {})
  716. },
  717. handleItem(row) {
  718. this.propertyTemplateItem = { ...row }
  719. this.handleQueryPropertyTemplateDetail()
  720. this.getRoleSelect()
  721. this.itemVisible = true
  722. },
  723. handleSaveItem(row) {
  724. this.item = {
  725. itemNo: '',
  726. itemDesc: '',
  727. site: this.propertyTemplateItem.site,
  728. itemType: this.propertyTemplateItem.functionType,
  729. headerId: this.propertyTemplateItem.id,
  730. }
  731. this.handleQueryItem()
  732. },
  733. handleQueryItem() {
  734. let params = {
  735. ...this.item,
  736. }
  737. queryPropertyTemplateDetailItem(params)
  738. .then(({ data }) => {
  739. if (data && data.code === 0) {
  740. this.itemList1 = data.rows
  741. this.itemSaveVisible = true
  742. } else {
  743. this.$message.warning(data.msg)
  744. }
  745. })
  746. .catch((error) => {
  747. this.$message.error(error)
  748. })
  749. },
  750. handleRowClick1(row) {
  751. this.$refs.itemTable1.toggleRowSelection(row, true)
  752. },
  753. handleRowClick2(row) {
  754. this.$refs.itemTable2.toggleRowSelection(row, true)
  755. },
  756. selectionItem1(val) {
  757. this.selectionList1 = val
  758. },
  759. selectionItem2(val) {
  760. this.selectionList2 = val
  761. },
  762. handleAddItem() {
  763. if (this.selectionList1.length === 0) {
  764. this.$message.warning('请选择属性项目')
  765. return
  766. }
  767. let params = this.selectionList1.map((item) => {
  768. return {
  769. site: this.propertyTemplateItem.site,
  770. functionType: this.propertyTemplateItem.functionType,
  771. codeNo: this.propertyTemplateItem.codeNo,
  772. propertiesItemNo: item.propertiesItemNo,
  773. createBy: this.$store.state.user.name,
  774. headerId: this.propertyTemplateItem.id,
  775. }
  776. })
  777. batchSavePropertyTemplateDetail(params)
  778. .then(({ data }) => {
  779. if (data && data.code === 0) {
  780. this.$message.success(data.msg)
  781. this.handleQueryItem()
  782. this.handleQueryPropertyTemplateDetail()
  783. } else {
  784. this.$message.warning(data.msg)
  785. }
  786. })
  787. .catch((error) => {
  788. this.$message.error(error)
  789. })
  790. },
  791. handleRemoveBatchItem() {
  792. if (this.selectionList2.length === 0) {
  793. this.$message.warning('请选择属性项目')
  794. return
  795. }
  796. this.$confirm('确认删除该属性项目吗?', '提示', {
  797. confirmButtonText: '确定',
  798. cancelButtonText: '取消',
  799. type: 'warning',
  800. })
  801. .then(() => {
  802. let params = this.selectionList2.map((item) => {
  803. return {
  804. id: item.id,
  805. }
  806. })
  807. removeBatchPropertyTemplateDetail(params)
  808. .then(({ data }) => {
  809. if (data && data.code === 0) {
  810. this.$message.success(data.msg)
  811. this.handleQueryItem()
  812. this.handleQueryPropertyTemplateDetail()
  813. } else {
  814. this.$message.warning(data.msg)
  815. }
  816. })
  817. .catch((error) => {
  818. this.$message.error(error)
  819. })
  820. })
  821. .catch(() => {})
  822. },
  823. handleQueryPropertyTemplateDetail() {
  824. let params = {
  825. headerId: this.propertyTemplateItem.id,
  826. }
  827. queryPropertyTemplateDetail(params)
  828. .then(({ data }) => {
  829. if (data && data.code === 0) {
  830. this.itemList2 = data.list
  831. } else {
  832. this.$message.warning(data.msg)
  833. }
  834. })
  835. .catch((error) => {
  836. this.$message.error(error)
  837. })
  838. },
  839. handleRemoveItem(row) {
  840. this.$confirm('确认删除该属性项目吗?', '提示', {
  841. confirmButtonText: '确定',
  842. cancelButtonText: '取消',
  843. type: 'warning',
  844. })
  845. .then(() => {
  846. let params = {
  847. id: row.id,
  848. }
  849. removePropertyTemplateDetail(params)
  850. .then(({ data }) => {
  851. if (data && data.code === 0) {
  852. this.$message.success(data.msg)
  853. this.handleQueryPropertyTemplateDetail()
  854. } else {
  855. this.$message.warning(data.msg)
  856. }
  857. })
  858. .catch((error) => {
  859. this.$message.error(error)
  860. })
  861. })
  862. .catch(() => {})
  863. },
  864. updateItemSort(row, index, type) {
  865. let currentSort = row.orderId
  866. console.log('1111', index, type)
  867. let nexRow = { ...this.itemList2[index + type] }
  868. let current = { ...row }
  869. current.orderId = nexRow.orderId
  870. nexRow.orderId = currentSort
  871. let params = [current, nexRow]
  872. batchUpdatePropertyTemplateDetail(params)
  873. .then(({ data }) => {
  874. if (data && data.code === 0) {
  875. this.$message.success(data.msg)
  876. this.handleQueryPropertyTemplateDetail()
  877. } else {
  878. this.$message.warning(data.msg)
  879. }
  880. })
  881. .catch((error) => {
  882. this.$message.error(error)
  883. })
  884. },
  885. handleChooseValue(row) {
  886. this.availableForm = {
  887. itemNo: row.itemNo,
  888. itemDesc: row.itemDesc,
  889. itemId: row.itemId,
  890. }
  891. this.handleQueryPropertyItemAvailable()
  892. this.valueChooseFlagVisible = true
  893. },
  894. handleQueryPropertyItemAvailable() {
  895. let params = {
  896. itemId: this.availableForm.itemId,
  897. }
  898. queryPropertyItemAvailable(params)
  899. .then(({ data }) => {
  900. if (data && data.code === 0) {
  901. this.availableList = data.rows
  902. } else {
  903. this.$message.warning(data.msg)
  904. }
  905. })
  906. .catch((error) => {
  907. this.$message.error(error)
  908. })
  909. },
  910. getSiteByUserName() {
  911. let params = {
  912. username: this.$store.state.user.name,
  913. }
  914. getSiteByUserName(params)
  915. .then(({ data }) => {
  916. if (data && data.code === 0) {
  917. this.userSiteList = data.list
  918. this.$set(
  919. this.saveForm,
  920. 'site',
  921. this.userSiteList.length > 0 ? this.userSiteList[0].deptId : ''
  922. )
  923. } else {
  924. this.$message.warning(data.msg)
  925. }
  926. })
  927. .catch((error) => {
  928. this.$message.error(error)
  929. })
  930. },
  931. getRoleSelect() {
  932. let params = {}
  933. getRoleSelect(params)
  934. .then(({ data }) => {
  935. if (data && data.code === 0) {
  936. this.roleIdList = data.list
  937. } else {
  938. this.$message.warning(data.msg)
  939. }
  940. })
  941. .catch((error) => {
  942. this.$message.error(error)
  943. })
  944. },
  945. //批量保存所有项目清单
  946. itemListBatchSave() {
  947. let nexRow = this.itemList2
  948. this.itemListLoading = true
  949. batchUpdatePropertyTemplateDetail(nexRow)
  950. .then(({ data }) => {
  951. if (data && data.code === 0) {
  952. this.$message.success(data.msg)
  953. this.itemVisible = false
  954. this.handleQueryByPage()
  955. } else {
  956. this.$message.warning(data.msg)
  957. }
  958. })
  959. .catch((error) => {
  960. this.$message.error(error)
  961. })
  962. .finally(() => {
  963. this.itemListLoading = false
  964. })
  965. },
  966. /** 重置按钮操作 */
  967. resetQuery() {
  968. this.resetForm('queryForm')
  969. this.handleQueryByPage()
  970. },
  971. },
  972. }
  973. </script>
  974. <!-- <style scoped lang="scss">
  975. 改变字典中的样式
  976. .el-tag {
  977. background-color: transparent!important;
  978. color: red!important;
  979. border: 0px!important;
  980. }
  981. .itemListClass {
  982. /deep/.tableBox {
  983. th {
  984. padding: 0 !important;
  985. height: 10px;
  986. line-height: 10px;
  987. }
  988. td {
  989. padding: 0 !important;
  990. height: 30px;
  991. line-height: 30px;
  992. }
  993. }
  994. }
  995. </style> -->
  996. <style scoped>
  997. /deep/ .itemListClass .cell {
  998. line-height: 20px;
  999. font-size: 12px;
  1000. height: 20px;
  1001. }
  1002. </style>