新增流程列表编辑功能
This commit is contained in:
@@ -20,7 +20,18 @@ function loadComponentOptions(filePath) {
|
||||
}
|
||||
|
||||
const stubImports = importNames.map(name => `const ${name} = {};`).join('\n')
|
||||
const transformed = `${stubImports}\n${scriptMatch[1]}`
|
||||
const namedImportStubs = `
|
||||
const listWorkflow = function() {};
|
||||
const getWorkflowEdit = function() {};
|
||||
const formatRate = function(value) { return value; };
|
||||
const mapGetters = function(names) {
|
||||
const result = {};
|
||||
names.forEach((name) => {
|
||||
result[name] = function() { return ''; };
|
||||
});
|
||||
return result;
|
||||
};`
|
||||
const transformed = `${stubImports}\n${namedImportStubs}\n${scriptMatch[1]}`
|
||||
.replace(/^import .*$/gm, '')
|
||||
.replace(/export default/, 'module.exports =')
|
||||
|
||||
@@ -37,8 +48,13 @@ function loadComponentOptions(filePath) {
|
||||
|
||||
const filePath = path.resolve(__dirname, '../src/views/loanPricing/workflow/index.vue')
|
||||
const component = loadComponentOptions(filePath)
|
||||
const source = fs.readFileSync(filePath, 'utf8')
|
||||
|
||||
assert.strictEqual(typeof component.activated, 'function', '流程列表页应在激活时刷新数据')
|
||||
assert(source.includes('icon="el-icon-edit"') && source.includes('>编辑</el-button>'), '流程列表操作列应包含编辑按钮')
|
||||
assert(source.includes('v-if="canEdit(scope.row)"'), '流程列表编辑按钮应只对可编辑行显示')
|
||||
assert(source.includes('row.createBy === this.currentCreateBy'), '流程列表应按创建者判断编辑按钮权限')
|
||||
assert(source.includes('getWorkflowEdit(row.serialNum)'), '编辑操作应先查询编辑数据')
|
||||
|
||||
let refreshCount = 0
|
||||
component.activated.call({
|
||||
@@ -49,4 +65,16 @@ component.activated.call({
|
||||
|
||||
assert.strictEqual(refreshCount, 1, '流程列表页激活时应调用一次 getList')
|
||||
|
||||
assert.strictEqual(component.methods.canEdit.call({
|
||||
currentCreateBy: '张三-8920001'
|
||||
}, {
|
||||
createBy: '张三-8920001'
|
||||
}), true, '创建者应允许编辑')
|
||||
|
||||
assert.strictEqual(component.methods.canEdit.call({
|
||||
currentCreateBy: '张三-8920001'
|
||||
}, {
|
||||
createBy: '李四-8920002'
|
||||
}), false, '非创建者不应允许编辑')
|
||||
|
||||
console.log('workflow-index-refresh test passed')
|
||||
|
||||
Reference in New Issue
Block a user